Skip to content

GROOVY-12203: False positive "name clash" for a valid override when a… - #2742

Open
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12203
Open

GROOVY-12203: False positive "name clash" for a valid override when a…#2742
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12203

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

? super wildcard uses a type that declares the same type variable name

… `? super` wildcard uses a type that declares the same type variable name

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.compareGenericsWithBound to avoid substituting a placeholder with a wildcard argument from classNodePlaceholders.
  • 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-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.8622%. Comparing base (023b9f5) to head (bcd6d90).

Additional details and impacted files

Impacted file tree graph

@@                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     
Files with missing lines Coverage Δ
...ain/java/org/codehaus/groovy/ast/GenericsType.java 87.7193% <100.0000%> (+0.1087%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Jul 28, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: bcd6d90
▶️ Tests: 106887 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants