Skip to content

Match type for extracting type parameter fails to reduce #18488

Closed
@KuceraMartin

Description

@KuceraMartin

Compiler version

3.3.0

Minimized code

The code is still quite big but I have not been able to minimize it further.

trait AbstractTable[T]

trait Query[E, U]

class TableQuery[E <: AbstractTable[?]] extends Query[E, Extract[E]]

type Extract[E] = E match
  case AbstractTable[t] => t

trait BaseCrudRepository[E[T[_]]]:

  type EntityTable <: AbstractTable[E[Option]]

  def filterById: Query[EntityTable, Extract[EntityTable]] =
    new TableQuery[EntityTable]

Output

[error] ./match-type.scala:15:5
[error] Match type reduction failed since selector  T
[error] matches none of the cases
[error]
[error]     case AbstractTable[t] => t
[error]     new TableQuery[EntityTable]
[error]     ^

Expectation

The code should compile. It compiles with Scala 3.1 and also with 3.4.0-RC1-bin-20230829-510aac8-NIGHTLY but not with 3.2 or 3.3.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions