Reject non-exhaustive nested sealed record patterns in switch #5182#5192
Open
kamilkrzywanski wants to merge 1 commit into
Open
Reject non-exhaustive nested sealed record patterns in switch #5182#5192kamilkrzywanski wants to merge 1 commit into
kamilkrzywanski wants to merge 1 commit into
Conversation
…-jdt#5182 When exhaustiveness checks a sealed switch selector, a case whose type is a permitted record was treated as covering that record even if nested record patterns only matched some of the component's sealed subtypes (e.g. Absolute(GlobalPosition) without Absolute(StartPosition)). For permitted records, reuse existing record-pattern coverage so ECJ matches javac and JLS 14.11.1.1. Add regression tests. Fixes eclipse-jdt#5182 Signed-off-by: Kamil Krzywannski <kamilkrzywanski01@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
case Absolute(GlobalPosition p)without coveringAbsolute(StartPosition)).MatchException.javaccorrectly rejects the same code.RNode/CoverageCheckerVisitor) so nested components are checked (JLS 14.11.1.1). Type patterns such ascase Absolute astill fully cover the record.SwitchPatternTest.Fixes #5182
Test plan
javac(rejected) using the issue sampleSwitchPatternTest— 334 tests, 0 failures