Skip to content

Exhaustivity checks do not dealias types nested in or-types #2254

Closed
@abgruszecki

Description

@abgruszecki

As in the title:

scala> def m(s: Int | Float | String) = s match {
         case _: Int => ; case _: Float => ; case _: String => ; }
def m(s: Int | Float | String): Unit
scala> type OrAlias = Int | Float
defined type alias OrAlias
scala> def m(s: OrAlias | String) = s match {
         case _: Int => ; case _: Float => ; case _: String => ; }
-- [E028] Pattern Match Exhaustivity Warning: <console> ------------------------
5 |def m(s: OrAlias | String) = s match {
  |                             ^
  |                             match may not be exhaustive.
  |
  |                             It would fail on: _: OrAlias
6 |  case _: Int => ; case _: Float => ; case _: String => ; }
def m(s: OrAlias | String): Unit

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions