You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
objectO {
sealedtraitFruitobjectAppleextendsFruitobjectBananaextendsFruitsealedclassC(f1: Fruit, f2: Fruit)
objectC {
defunapply(c: C):Some[Banana.type] =Some(Banana)
}
defm(c: C) = c match { caseC(b) => b }
}
produces the following message:
-- [E028] Pattern Match Exhaustivity Warning: <console>:12:16 ------------------
12 | def m(c: C) = c match { case C(b) => b }
| ^
| match may not be exhaustive.
|
| It would fail on: C(Apple, _)
The pattern match is, in fact, exhaustive and the message is somewhat puzzling.
As a simple example, the following code:
produces the following message:
The pattern match is, in fact, exhaustive and the message is somewhat puzzling.
The underlying issue is the interaction between this code in the
project
method:https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala#L430-L431
and the places in rest of the code which "project"
Typ(tp)
asKon(tp, signature(tp).map(Typ(_))
:https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala#L267
When a
Kon
space resulting from projectingC.unapply
is subtracted fromTyp(C)
, "inconsistent"Kon
spaces are created, which then in turn causes this issue./cc @liufengyun
The text was updated successfully, but these errors were encountered: