bug
bug copied to clipboard
Type bounds checks are deferred?
Hello team, please consider following code snippet.
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 9.0.1).
Type in expressions for evaluation. Or try :help.
scala> :pa
// Entering paste mode (ctrl-D to finish)
trait Target {
type Value = Int
type Apply[F[_]] = F[Value]
}
trait Box {
type Inner
}
type Unbox[B <: Box] = B#Inner
// Exiting paste mode, now interpreting.
defined trait Target
defined trait Box
defined type alias Unbox
scala> type Result1 = Target#Apply[Unbox] // will not compile
<console>:13: error: kinds of the type arguments (Unbox) do not conform to the expected kinds of the type parameters (type F).
Unbox's type parameters do not match type F's expected parameters:
type B's bounds <: Box are stricter than type _'s declared bounds >: Nothing <: Any
type Result1 = Target#Apply[Unbox] // will not compile
^
scala> type Result2 = Target#Apply[({type R[V] = Unbox[V]})#R] // shouldn't compile as well
defined type alias Result2
scala> :pa
// Entering paste mode (ctrl-D to finish)
trait Target {
trait Value
type Apply[F[_]] = F[Value]
}
// Exiting paste mode, now interpreting.
defined trait Target
scala> type Result1 = Target#Apply[Unbox] // also shouldn't compile?
defined type alias Result1
scala>
Should I expect all the cases to not compile?
"fixed in Scala 3" in the sense that B#Inner was deliberately made illegal