Skip to content

Compiler regression in type inferrence of Enum-singletons #25742

@felix-hedenstrom

Description

@felix-hedenstrom

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:enumsarea:inferitype:bugregressionThis worked in a previous version but doesn't anymorestat:needs bisectionNeed to use nightly builds and git bisect to find out the commit where this issue was introduced

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions