Skip to content

Pattern matching with an AnyVal scrutinee fails with unreachable case error #7783

Closed
@milessabin

Description

@milessabin

Compiling this,

object Test {
  def foo(t: AnyVal): Unit = t match {
    case _: Int =>
  }
}

gives me the following unreachable case error rather than the non-exhaustivity warning I was hoping for,

-- Error: local/nulls.scala:3:9 ------------------------------------------------
3 |    case _: Int =>
  |         ^
  |this case is unreachable since class AnyVal and class Integer are unrelated
1 error found

Assuming this is a bug and that this should instead give us a warning about a non-exhaustive match, then does this make the introduction of Null as a subtype of AnyVal with -Yexplict-nulls in #7546 problematic? Presumably the extra case would make previously exhaustive matches over existing AnyVals non-exhaustive?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions