Skip to content

Unsound match type conformance when extending trait from separate compilation #20189

Open
@EugeneFlesselle

Description

@EugeneFlesselle

Compiler version

3.5.0-RC1

Minimized code

A_1.scala

type M[X] = X match
  case 0 => String
  case 1 => Int

trait A:
  type T
  val str: M[0 & T] = "hello"
  val int: M[1 & T]

B_2.scala

trait B extends A:
  type T = 0 & 1
  val int = str

@main def Test =
  val a: A = new B {}
  val i: Int = a.int

Output

java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:match-typesitype:bugitype:soundnessSoundness bug (it lets us compile code that crashes at runtime with a ClassCastException)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions