Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
EugeneFlesselle opened this issue Apr 15, 2024 · 0 comments
Labels
area:match-types itype:bug itype:soundness Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)

Comments

@EugeneFlesselle
Copy link
Contributor

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
@EugeneFlesselle EugeneFlesselle added itype:bug area:match-types itype:soundness Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException) labels Apr 15, 2024
@EugeneFlesselle EugeneFlesselle changed the title Unsound match type conformance when refining a trait with separate compilation Unsound match type conformance when extending trait from separate compilation Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:match-types itype:bug itype:soundness Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)
Projects
None yet
Development

No branches or pull requests

1 participant