Closed som-snytt closed 8 months ago
I agree with the compiler. The match only handles Tombstone
, K
and null
. It doesn't handle all the other values.
@unchecked
is not a cast that says: "actually match an Any
then cast to K
". It shouldn't be used as one. What it does is to tell the compiler: "match a K
, but don't worry if you're not able to emit all the necessary tests, just do the ones you can".
Using @unchecked
instead of casts is bound to end up in this kind of issues.
The other part of the two-part ticket is that the message should be a reasonable approximation of actionable. I'd rather it just said, "There's something fishy about your match, but darned if I know what."
I don't mind whatever you call mechanical sympathy for pattern matching.
(But I didn't try any debug options if there is additional output.)
Also, thanks for the helpful clarification. I thought I was thinking about unchecked correctly, because you are literally quoting me when I patted the compiler on the shoulder and said, "Don't worry about it, just do your best." But maybe I had an ulterior motive.
Reproduction steps
Scala version: 2.13.12
Problem
This is likely a duplicate of some other ticket where they expected either no warning or a plausibly accurate one.
In this case, the Vector is really
Vector[Tombstone | K | Null]
. I guess the three cases areTombstone
,not-Null
(sinceK
is unchecked), andnull
. So I expect no warning.The IRL roundtrip was through
@nowarn("cat=other-match-analysis&msg=match may not be exhaustive")
and then changing thenull
case tocase nullish @ _ =>
and then remembering to delete the annotation.