Skip to content

Strange type printed by REPL #3603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
odersky opened this issue Nov 29, 2017 · 1 comment
Closed

Strange type printed by REPL #3603

odersky opened this issue Nov 29, 2017 · 1 comment

Comments

@odersky
Copy link
Contributor

odersky commented Nov 29, 2017

When running REPL test i2554, we fail in PR #3602 as follows:

expected =========>
    scala> object foo { trait ShapeLevel; trait FlatShapeLevel extends ShapeLevel; trait 
ColumnsShapeLevel extends FlatShapeLevel; abstract class Shape[Level <: ShapeLevel, -Mixed, 
Unpacked, Packed]; object Shape extends TupleShapeImplicits { }; trait TupleShapeImplicits { 
implicit final def tuple2Shape[Level <: ShapeLevel, M1,M2, U1,U2, P1,P2](implicit u1: Shape[_ <: 
Level, M1, U1, P1], u2: Shape[_ <: Level, M2, U2, P2]): Shape[Level, (M1,M2), (U1,U2), (P1,P2)] = 
???; }; }
// defined object foo
scala> import foo._
scala> implicit val shape: Shape[_ <: FlatShapeLevel, Int, Int, _] = null
implicit val shape: foo.Shape[_ <: foo.FlatShapeLevel, Int, Int, _] = null
scala> def hint = Shape.tuple2Shape(shape, shape)
def hint: foo.Shape[foo.FlatShapeLevel, (Int, Int), (Int, Int), (_, _)]
actual ===========>
scala> object foo { trait ShapeLevel; trait FlatShapeLevel extends ShapeLevel; trait 
ColumnsShapeLevel extends FlatShapeLevel; abstract class Shape[Level <: ShapeLevel, -Mixed, 
Unpacked, Packed]; object Shape extends TupleShapeImplicits { }; trait TupleShapeImplicits { 
implicit final def tuple2Shape[Level <: ShapeLevel, M1,M2, U1,U2, P1,P2](implicit u1: Shape[_ <: 
Level, M1, U1, P1], u2: Shape[_ <: Level, M2, U2, P2]): Shape[Level, (M1,M2), (U1,U2), (P1,P2)] = 
???; }; }
// defined object foo
scala> import foo._
scala> implicit val shape: Shape[_ <: FlatShapeLevel, Int, Int, _] = null
implicit val shape: foo.Shape[_ <: foo.FlatShapeLevel, Int, Int, _] = null
scala> def hint = Shape.tuple2Shape(shape, shape)
def hint: foo.Shape[foo.FlatShapeLevel, (Int, Int), (Int, Int), ()]
[error] Test dotty.tools.repl.ScriptedTests.replTests failed: java.lang.AssertionError: Error in file 
/Users/odersky/workspace/dotty/compiler/target/scala-2.12/test-classes/repl/i2554, expected 
output did not match actual, took 3.684 sec

The culprit is the last line:

def hint: foo.Shape[foo.FlatShapeLevel, (Int, Int), (Int, Int), ()]

In fact, () is not a legal type syntax, so something strange is happening here. If I run the analogous test tests/pos/i2554.scala in the normal compiler, I get:

def hint: 
  foo.Shape[foo.FlatShapeLevel, (Int, Int), (Int, Int), (
      foo.Shape[_ <: foo.FlatShapeLevel, Int, Int, _]#Packed
    , foo.Shape[_ <: foo.FlatShapeLevel, Int, Int, _]#Packed)]

Instead of the tuple with the two #Packed types, the REPL prints the ().

Note that without #3602 the REPL prints (_, _), but this is actually wrong. For comparison, scalac, which has existential types prints:

def hint: 
  foo.Shape[foo.FlatShapeLevel,(Int, Int),(Int, Int),(_$4, _$4)] 
  forSome { type _$4; type _$4 }

Note that this is not the same as (_, _) because the quantifier scope is wrong.

@smarter
Copy link
Member

smarter commented Nov 29, 2017

This is fixed by #3566

@smarter smarter closed this as completed Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants