GROOVY-11754: STC: prevent cast exception under imbalanced instanceof#2397
Open
eric-milles wants to merge 1 commit intoGROOVY_5_0_Xfrom
Open
GROOVY-11754: STC: prevent cast exception under imbalanced instanceof#2397eric-milles wants to merge 1 commit intoGROOVY_5_0_Xfrom
instanceof#2397eric-milles wants to merge 1 commit intoGROOVY_5_0_Xfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## GROOVY_5_0_X #2397 +/- ##
======================================================
+ Coverage 67.1286% 67.1339% +0.0053%
- Complexity 29422 29430 +8
======================================================
Files 1382 1382
Lines 116758 116789 +31
Branches 20462 20471 +9
======================================================
+ Hits 78378 78405 +27
- Misses 31902 31903 +1
- Partials 6478 6481 +3
🚀 New features to boost your workflow:
|
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.
Changes to
StaticTypesTypeChooserin Groovy 5 caused a cast exception at runtime for statically-compiled imbalanced-instanceofscenarios likeif (cn instanceof InnerClassNode || cn.isEnum()). This traces back to the temp types storage in STC. For the statement above, onlyInnerClassNodeis saved as a temp type. When the temp type is computed for "cn.isEnum()",InnerClassNodeis the result.A small part of the GROOVY-7971 solution is to mix in the original variable type in a scenario such as this -- to express the optionality of instance check(s). I back-ported just this part of the larger solution. This stops the cast exception for the GROOVY-11754 scenario. This is a pre-condition for introducing the GROOVY-11769
StaticTypesTypeChooserchange (see #2311) into Groovy 4.