Skip to content

Compiler regression in type inferrence #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

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions