Skip to content

Match type reduction fails, but works with minor tweaks #16869

Closed
@KuceraMartin

Description

@KuceraMartin

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions