GROOVY-11974: stub generator could emit records into stubs when in na…#2502
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
JavaStubGeneratorto emitrecord Foo(...)stubs (and avoid emitting illegal record constructs like instance fields / explicitfinal/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 Report❌ Patch coverage is Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
…tive records mode
90dacc5 to
b393a1a
Compare
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.
…tive records mode
https://issues.apache.org/jira/browse/GROOVY-11974