Is your feature request related to a problem? Please describe.
The compiler (3.3.1) seems to be aware of exhaustivity of a union type argument:
scala> trait ID
| case class UserName(name: String) extends ID
| case class Password(hash: Int) extends ID
// defined trait ID
// defined case class UserName
// defined case class Password
scala> def help(id: UserName | Password) = id match
| case UserName(name) => name
| // omitting the Password(hash) case on purpose
1 warning found
-- [E029] Pattern Match Exhaustivity Warning: -------------------------------------------------------------------------
1 |def help(id: UserName | Password) = id match
| ^^
| match may not be exhaustive.
|
| It would fail on pattern case: Password(_)
|
| longer explanation available when compiling with `-explain`
def help(id: UserName | Password): String
But we don't get an exhaustive match option for them, like we do for enums or other matchable types:
Describe the solution you'd like
Would it be possible to get match (exhaustive) option there?
Is your feature request related to a problem? Please describe.
The compiler (3.3.1) seems to be aware of exhaustivity of a union type argument:
But we don't get an exhaustive match option for them, like we do for
enum
s or other matchable types:Describe the solution you'd like
Would it be possible to get
match (exhaustive)
option there?Describe alternatives you've considered
(no alternatives)
Additional context
Might be relevant https://github.com/scalameta/metals-feature-requests/issues/317
Search terms
union types pattern matching exhaustivity