GROOVY-12203: False positive "name clash" for a valid override when a… - #2742
Open
paulk-asert wants to merge 1 commit into
Open
GROOVY-12203: False positive "name clash" for a valid override when a…#2742paulk-asert wants to merge 1 commit into
paulk-asert wants to merge 1 commit into
Conversation
… `? super` wildcard uses a type that declares the same type variable name
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes GROOVY-12203 by adjusting generics-bound comparison so that a wildcard generic argument is not treated as instantiating a type variable (avoiding a false-positive “name clash” / non-override determination when type-variable names coincide across scopes, e.g., within ? super ... bounds).
Changes:
- Update
GenericsType.compareGenericsWithBoundto avoid substituting a placeholder with a wildcard argument fromclassNodePlaceholders. - Add a regression test ensuring valid overrides compile when
Box<? super T>/Box<? extends T>is used with method type parameters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/test/groovy/groovy/OverrideTest.groovy | Adds a regression test reproducing GROOVY-12203 with overrides involving ? super / ? extends wildcards. |
| src/main/java/org/codehaus/groovy/ast/GenericsType.java | Prevents wildcard arguments from being used to “instantiate” a type variable during generics bound comparison. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2742 +/- ##
==================================================
- Coverage 69.8687% 69.8622% -0.0064%
- Complexity 35137 35141 +4
==================================================
Files 1554 1554
Lines 130731 130733 +2
Branches 23916 23918 +2
==================================================
- Hits 91340 91333 -7
- Misses 31145 31150 +5
- Partials 8246 8250 +4
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: bcd6d90 Learn more about TestLens at testlens.app. |
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.
…
? superwildcard uses a type that declares the same type variable name