Prune impossible types from exhaustivity checker #3574
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The exhaustivity checker sometimes looks for impossible types.
The test case added by this PR is an example taken from the shapeless test suite where a sealed trait is extended in two different scopes. The added case classes
One
andTwo
can only appear withing objectAtoms01
andAtoms02
respectively. On master the exhaustivity checker reports missing cases of the following form:PathVariantDefns.Atom2 & PathVariantDefns.Atoms01.type(PathVariantDefns.Atoms01).Two(_)
. Given thatPathVariantDefns.Atoms01.type
is the type of an object, the intersection between this type and any unrelated type is always empty. This PR adds a check toinstantiate
that detect and remove these cases.@liufengyun WDYT?