Unnecessary exhaustivity warning when combining refinement types w/ params
See original GitHub issueThe following code:
object O {
sealed trait Trait[+A] { type T }
case class CaseClass[+A](a: A) extends Trait[A] { type T = Nothing }
def id[TT, A](v: Trait[A] { type T = TT }): Trait[A] { type T = TT } =
v match {
case CaseClass(a) => CaseClass(a)
}
}
causes the following warning:
-- [E028] Pattern Match Exhaustivity Warning: sample/1:6:4 ---------------------
6 | v match {
| ^
| match may not be exhaustive.
|
| It would fail on: CaseClass(_)
@liufengyun - this happens because the refinement type forces usage of typeParamMap
in instantiate
. This in turn initializes the param in the pattern space to Any
, so instead of CaseClass[A]
we get CaseClass[Any]
. This was found when rebasing #3454 - one test had to be ignored. I should also mention that with the POC typechecker integration I’ve described in #3454, this code is handled correctly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
GADT exhaustiveness check incompleteness #6437 - GitHub
reports a warning for non-exhaustive pattern-matching; but whatever the value of t is, the second argument cannot be U1 (this branch 4 is...
Read more >Filters and facet filters - Algolia
There is one rule: we combine them using AND - meaning, we take the set of filters from each parameter and link them...
Read more >Characterisation of molecular motions in cryo-EM single ...
We describe a new tool, called multi-body refinement, which models flexible complexes as a user-defined number of rigid bodies that move ...
Read more >Exhaustive Testing - an overview | ScienceDirect Topics
Exhaustive testing requires applying 2 n exhaustive patterns to an n-input ... These new tests are executed to refine the suspicious combination set....
Read more >Technical_Reference.pdf - TOPAS-Academic
LARGE REFINEMENTS WITH TENS OF 1000S OF PARAMETERS. ... Superfluous parentheses and the '&' Type for macros .
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
Ah, I think I was misunderstanding wildcard semantics! After some experimentation, it appears that for instance
Dog[_]
is precisely what I would denote asDog[K] forSome K
. I understand now why using wildcards is correct here.However, I’m not sure if I properly explained how or why I want to use TVars: once a TVar was used in a space’s type anywhere, its constraints kept in that space’s
Context
are not adjusted. TVars are only there so that additional constraints can be added to newContext
s created when decomposing spaces. I wanted to highlight that if we go through with typechecker-integrated #3454, this issue would automagically be solved as well.Fixed in https://github.com/lampepfl/dotty/pull/3475.