Skip to content

Unsound conformance from selection of member MatchType #19949

Closed
@EugeneFlesselle

Description

@EugeneFlesselle

Match type with no cases reduces to unreported ErrorType

Compiler version

3.4.2-RC1

Minimized code

trait T[N]:
  type M = N match
    case 0 => Any // or anything else

val t: T[Double] = new T[Double] {}
val x: t.M = "hello"
val y: Boolean = x // compiles + ClassCastException

We also have the same issue when using a projection:

val z: T[Double]#M = "hello"
val _: Boolean = z // compiles + ClassCastException

Minimised from @Gedochao's #19936 (comment)

Metadata

Metadata

Labels

area:match-typesitype:bugitype:soundnessSoundness bug (it lets us compile code that crashes at runtime with a ClassCastException)regressionThis worked in a previous version but doesn't anymore

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions