scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.88k stars 1.06k forks source link

enum with AnyKind-ed type param instantiated to different kinds does not compile #22003

Open TomasMikula opened 22 hours ago

TomasMikula commented 22 hours ago

Compiler version

3.5.0 3.6.1

Minimized code

enum Foo[T <: AnyKind]:
  case Bar extends Foo[List]
  case Baz extends Foo[Map]

Output

Found:    (Playground.Foo.Bar : Playground.Foo[List]) |
  (Playground.Foo.Baz : Playground.Foo[Map])
Required: Playground.Foo[? >: List[?] & Map[?, ?] <: List[?] | Map[?, ?]]

https://scastie.scala-lang.org/A8kJXNH1QMSMPOQe6DmCJg

Expectation

It should compile, like this equivalent sealed family:

// compiles
sealed trait Foo[T <: AnyKind]
case object Bar extends Foo[List]
case object Baz extends Foo[Map]