Skip to content

GROOVY-11974: stub generator could emit records into stubs when in na…#2502

Merged
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy11974
Apr 30, 2026
Merged

GROOVY-11974: stub generator could emit records into stubs when in na…#2502
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy11974

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

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-11974 by ensuring joint-compilation stub generation preserves Java record semantics for Groovy “native records”, so Java sources compiled against the stubs can see the canonical constructor and componentName() accessors.

Changes:

  • Add RecordTypeASTTransformation.wouldBeNativeRecord(...) to predict native-record outcome before the record transform runs.
  • Update JavaStubGenerator to emit record Foo(...) stubs (and avoid emitting illegal record constructs like instance fields / explicit final / extends Object).
  • Add a joint-compilation stub test covering record-stub header and forbidden stub elements.

Reviewed changes

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

File Description
src/test/groovy/org/codehaus/groovy/tools/stubgenerator/RecordTypeJointCompilationStubTest.groovy Adds regression test ensuring generated stubs use record syntax and omit invalid record elements.
src/main/java/org/codehaus/groovy/transform/RecordTypeASTTransformation.java Introduces a pre-transform predicate for “would compile as native record” and refactors native-record decision logic to reuse it.
src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java Emits record headers for native-record stubs and adjusts field/constructor emission to satisfy javac record rules.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 71.79487% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.0793%. Comparing base (a71d56f) to head (b393a1a).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...codehaus/groovy/tools/javac/JavaStubGenerator.java 78.5714% 2 Missing and 4 partials ⚠️
.../groovy/transform/RecordTypeASTTransformation.java 54.5454% 0 Missing and 5 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2502        +/-   ##
==================================================
- Coverage     67.0834%   67.0793%   -0.0041%     
- Complexity      31740      31755        +15     
==================================================
  Files            1465       1465                
  Lines          123327     123354        +27     
  Branches        22089      22102        +13     
==================================================
+ Hits            82732      82745        +13     
- Misses          33499      33502         +3     
- Partials         7096       7107        +11     
Files with missing lines Coverage Δ
.../groovy/transform/RecordTypeASTTransformation.java 84.7273% <54.5454%> (-1.3021%) ⬇️
...codehaus/groovy/tools/javac/JavaStubGenerator.java 86.1472% <78.5714%> (-0.1009%) ⬇️

... and 4 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 981cb53 into apache:master Apr 30, 2026
24 checks passed
@paulk-asert paulk-asert deleted the groovy11974 branch April 30, 2026 04:04
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