Compiler version
The problem exists in 3.8.x, it does not exist in 3.7.4 or 3.3.7
Minimized code
//> using scala 3.8.3
enum Foo(val id: Int) {
case Bar(override val id: Int, name: Option[String]) extends Foo(id)
}
def y[A](a: A): A = a
val bar: Foo.Bar = Foo.Bar(1, Some("x"))
val result = y(bar.copy(name = None))
val check: Foo.Bar = result
Output
[error] ./copy-issue2.scala:11:22
[error] Found: (result : Foo)
[error] Required: Foo.Bar
[error] val check: Foo.Bar = result
[error] ^^^^^^
Expectation
That it works like in scala versions before 3.8.x and compiles
Compiler version
The problem exists in 3.8.x, it does not exist in 3.7.4 or 3.3.7
Minimized code
Output
Expectation
That it works like in scala versions before 3.8.x and compiles