scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Some concrete dependent types are not properly expanded #10038

Open scabug opened 8 years ago

scabug commented 8 years ago
Welcome to Scala 2.12.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala> trait InvariantContainer[T0] {
     |   type T = T0
     | }
defined trait InvariantContainer

scala> type OptionalContainer[Container <: InvariantContainer[_]] = InvariantContainer[Option[Container#T]]
defined type alias OptionalContainer

scala> def expand(x: OptionalContainer[InvariantContainer[Int]]): InvariantContainer[Option[InvariantContainer[Int]#T]] = x
<console>:13: error: type mismatch;
 found   : OptionalContainer[InvariantContainer[Int]]
    (which expands to)  InvariantContainer[Option[_$1]]
 required: InvariantContainer[Option[Int]]
       def expand(x: OptionalContainer[InvariantContainer[Int]]): InvariantContainer[Option[InvariantContainer[Int]#T]] = x
                                                                                                                          ^

scala> def expand(x: OptionalContainer[InvariantContainer[Int]]): InvariantContainer[Option[Int]] = x
<console>:13: error: type mismatch;
 found   : OptionalContainer[InvariantContainer[Int]]
    (which expands to)  InvariantContainer[Option[_$1]]
 required: InvariantContainer[Option[Int]]
       def expand(x: OptionalContainer[InvariantContainer[Int]]): InvariantContainer[Option[Int]] = x
                                                                                                    ^

I expect that scalac does not error here, because T is a concrete type, which should be expanded immediately.

scabug commented 8 years ago

Imported From: https://issues.scala-lang.org/browse/SI-10038?orig=1 Reporter: @Atry Affected Versions: 2.12.0