Closed
Description
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.