Open
Description
Compiler version
3.6.4
(Works in 3.3.5) It does not, in fact, work in 3.3.5. Scastie just did not report any error.
Minimized code
sealed trait Foo[+T]
class Bar[+T] extends Foo[T]
def downcast[T](foo: Foo[T]): Bar[T] =
foo match
case b: Bar[t] =>
summon[t <:< T]
b
(snippet has been editted to make Bar
covariant)
https://scastie.scala-lang.org/EYEO0tDKSNqUJd4ypwRnKA
https://scastie.scala-lang.org/emJhbNmrQd2WYQEdjBzwow
Output
-- [E172] Type Error: test.scala:7:21 ------------------------------------------
7 | summon[t <:< T]
| ^
| Cannot prove that t <:< T.
-- [E007] Type Mismatch Error: test.scala:8:6 ----------------------------------
8 | b
| ^
| Found: (b : Foo[T] & Bar[t])
| Required: Bar[T]
|
| longer explanation available when compiling with `-explain`
2 errors found
Expectation
Should typecheck, as it does with Scala 3.3.5.