Spurious pattern exhaustivity warning when one type parameter lower-bounds another
See original GitHub issueThis example:
sealed trait Parent
final case class Leaf[A, B >: A](a: A, b: B) extends Parent
def run(x: Parent): Unit = x match {
case Leaf(a, b) =>
}
Leads to the following spurious warning:
-- [E029] Pattern Match Exhaustivity Warning:
6 |def run(x: Parent): Unit = x match {
| ^
| match may not be exhaustive.
|
| It would fail on pattern case: Leaf(_, _)
|
| longer explanation available when compiling with `-explain`
1 warning found
I suspect the issue to be different from #15522, since it is present on both main
and 3.1.2
.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
3.1.3 regression: spurious unreachable warning · Issue #15522 ...
Spurious pattern exhaustivity warning when one type parameter lower-bounds another #15523. Open. @dwijnand dwijnand self-assigned this on Jun 27.
Read more >scala - Type parameter circumvents match exhaustivity warning
If the selector of a pattern match is an instance of a sealed class, the compilation of pattern matching can emit warnings which...
Read more >Spurious Ambiguity and Focalization | Computational Linguistics
Spurious ambiguity is the phenomenon whereby distinct derivations in grammar may assign the same structural reading, resulting in redundancy in the parse ...
Read more >Declarations - Kotlin language specification
In all cases, it is forbidden if two or more secondary constructors form a delegation loop. Class constructors (both primary and secondary) may...
Read more >NUREG/CR-6823 - Handbook of Parameter Estimation for ...
Parameter Estimation Using Data from Different Sources .1-3 ... MLEs and 90% confidence intervals for p, for three types of demand and for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Related: I realized recently that despite our best effort we could still get recursion in lower bounds: https://github.com/lampepfl/dotty/issues/15280 and I have no idea how to deal with that properly
Note that the original test case is fixable just with the
frozen_<:<
change.So perhaps there’s yet another possible solution path here, namely:
Prevent the type avoidance crash (which only arises when we change the rhs of the pattern from
()
toa
) by making type avoidance (or whatever relevant piece of machinery that type avoidance is employing) not choke on the cycle.