Closed
Description
Compiler version
3.2.2
Minimized code
class C[T]
type Foo[T] = T match
case C[true] => true
case C[false] => false
class W[T] extends C[Foo[T]]
def f[T <: C[?]](t: T) = W[T]()
val b = C[true]()
f(b) : C[true]
https://scastie.scala-lang.org/MPU8IU46Q1GRYjcYu13S1g
Output
Compilation error:
Match type reduction failed since selector T matches none of the cases
case C[(true : Boolean)] => (true : Boolean)
case C[(false : Boolean)] => (false : Boolean)
Expectation
The code should compile. In fact there are many small tweaks that make it compile. For example:
- adding
case _
in the match type (even though this case is not used in the end): https://scastie.scala-lang.org/U7Tlij41Q6e9D28zxCJlZA - removing the upper bound
T <: C[?]
inf
: https://scastie.scala-lang.org/tVg5WBVbTlKVsv9v7PLHOw - storing
f(b)
into a val: https://scastie.scala-lang.org/tKqK9MMBQ6SNnwmmftuBlw - explicitly writing the type parameter of
f
when calling it: https://scastie.scala-lang.org/TyLKSgn9QISZDPiyfoqj0Q