Skip to content

GROOVY-11022: StackOverflowError when having parameterized function w…#2497

Open
paulk-asert wants to merge 1 commit intoapache:masterfrom
paulk-asert:groovy-11022-walkcontext
Open

GROOVY-11022: StackOverflowError when having parameterized function w…#2497
paulk-asert wants to merge 1 commit intoapache:masterfrom
paulk-asert:groovy-11022-walkcontext

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

@paulk-asert paulk-asert commented Apr 28, 2026

…ith recursive bounds

This is the fix recommended for master

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.1396%. Comparing base (5a41b8f) to head (2adae3b).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2497        +/-   ##
==================================================
+ Coverage     67.1374%   67.1396%   +0.0021%     
- Complexity      31622      31634        +12     
==================================================
  Files            1451       1451                
  Lines          122565     122582        +17     
  Branches        22007      22010         +3     
==================================================
+ Hits            82287      82301        +14     
- Misses          33199      33200         +1     
- Partials         7079       7081         +2     
Files with missing lines Coverage Δ
...roovy/transform/stc/StaticTypeCheckingSupport.java 81.8103% <100.0000%> (+0.2732%) ⬆️

... and 6 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.

Copy link
Copy Markdown

Copilot AI left a comment

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-11022 by preventing StackOverflowError during static type checking when expanding recursive (F-bounded) generic type parameter bounds that self-reference through wildcard bounds.

Changes:

  • Added regression tests covering recursive bounds involving ? super and ? extends wildcards.
  • Introduced a bound-expansion tracking context in StaticTypeCheckingSupport.applyGenericsContext to break cycles during placeholder bound expansion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy Adds a new regression test (testNoStackOverflow3) for recursive generic bounds cases.
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java Adds BoundExpansionContext and threads it through applyGenericsContext to avoid infinite recursion when expanding F-bounded placeholder bounds.

Comment thread src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy Outdated
Comment thread src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy Outdated
@paulk-asert paulk-asert force-pushed the groovy-11022-walkcontext branch from 82e029e to 2adae3b Compare April 28, 2026 12:30
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