Skip to content

match types do not support AnyKind #13757

Closed
@soronpo

Description

@soronpo

Not sure if this is a bug, a wanted limitation or just an overlook.
There are two issues with any-kinded types and match types.

  1. Inability to match against an any-kinded type.
  2. Inability to reduce an any-kinded type, when it "falls-in" the match through the "other" case clause.

Compiler version

Master branch

Minimized code

type Fix1[T <: AnyKind] = T match
  case Option[a] => Option[a]
  case Option    => Option[Int]

type Fix2[T <: AnyKind] = T match
  case Option[a] => Option[a]
  case _         => Option[Int]

Output

[error] 3 |  case Option    => Option[Int]
[error]   |       ^^^^^^
[error]   |       Missing type parameter for Option

[error] 5 |type Fix2[T <: AnyKind] = T match
[error]   |                            ^
[error]   |                            Match type reduction failed since selector  T
[error]   |                            matches none of the cases
[error]   |
[error]   |                                case Option[a] => Option[a]
[error]   |                                case _ => Option[Int]

Expectation

No error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions