Skip to content

GROOVY-11968: SC: trait static field access generates invalid bytecod…#2495

Merged
paulk-asert merged 1 commit intoapache:masterfrom
paulk-asert:groovy11968
May 1, 2026
Merged

GROOVY-11968: SC: trait static field access generates invalid bytecod…#2495
paulk-asert merged 1 commit intoapache:masterfrom
paulk-asert:groovy11968

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

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-11968 (follow-up to GROOVY-11907) where statically compiled trait static-field access could route sub-expressions through the regular (non-static) call-site writer, producing invalid bytecode under indy=false.

Changes:

  • Track whether the current statically compiled method contains any DYNAMIC_RESOLUTION sub-expressions (via an AST scan).
  • Ensure the regular CallSiteWriter per-method prologue is emitted at method entry when such dynamic-resolution sub-expressions exist.
  • Add a regression test that compiles and runs the reproducer script with indy=true and indy=false.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy11968.groovy New regression test covering helper verification under both indy modes
src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesWriterController.java Detects presence of DYNAMIC_RESOLUTION within statically compiled methods/ctors
src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java Emits regular call-site writer method prologue when needed to avoid invalid locals

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.1794%. Comparing base (839717c) to head (e98ad40).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
...y/classgen/asm/sc/StaticTypesWriterController.java 81.4815% 0 Missing and 5 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2495        +/-   ##
==================================================
+ Coverage     67.0917%   67.1794%   +0.0878%     
- Complexity      31765      31852        +87     
==================================================
  Files            1465       1465                
  Lines          123373     123511       +138     
  Branches        22107      22138        +31     
==================================================
+ Hits            82773      82974       +201     
+ Misses          33493      33400        -93     
- Partials         7107       7137        +30     
Files with missing lines Coverage Δ
...ovy/classgen/asm/sc/StaticTypesCallSiteWriter.java 78.7946% <100.0000%> (+0.5435%) ⬆️
...y/classgen/asm/sc/StaticTypesWriterController.java 91.5663% <81.4815%> (-4.8623%) ⬇️

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

@paulk-asert paulk-asert merged commit 84f2f37 into apache:master May 1, 2026
24 checks passed
@paulk-asert paulk-asert deleted the groovy11968 branch May 1, 2026 03:40
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.

4 participants