GROOVY-11970: Provide support for compound assignment operator overlo…#2499
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds GEP-15 support for dedicated compound-assignment operator overloads (e.g. plusAssign) across static type checking, bytecode generation, @OperatorRename, documentation, and tests.
Changes:
- Introduces
*Assignmethod resolution in the static type checker and propagates the resolved target to static codegen. - Adds dynamic-mode compound-assign dispatch via
ScriptBytecodeAdapter.compoundAssignand updates bytecode generation to use it. - Documents the feature in the operator spec and adds a focused test suite for compound assignment behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/groovy/groovy/operator/CompoundAssignmentTest.groovy | New tests covering static/dynamic *Assign selection, fallback behavior, final handling (static), setter skipping (static), and @OperatorRename scenarios. |
| src/spec/doc/core-operators.adoc | Documents compound assignment operator overloading and method mapping table. |
| src/main/java/org/codehaus/groovy/transform/stc/StaticTypesMarker.java | Adds metadata key to carry resolved *Assign target from STC into codegen. |
| src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java | Resolves *Assign methods for compound-assign tokens and records the chosen target; skips setter-info when in-place mutation applies. |
| src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java | Adds token→*Assign method-name mapping helper. |
| src/main/java/org/codehaus/groovy/transform/OperatorRenameASTTransformation.java | Extends @OperatorRename to support *Assign renames with precedence over base operator renames. |
| src/main/java/org/codehaus/groovy/syntax/Types.java | Treats REMAINDER_EQUAL as an assignment operator token. |
| src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java | Adds dynamic dispatcher helper for *Assign vs fallback operator call. |
| src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java | Emits in-place *Assign calls during static compilation when STC resolved a target; maintains legacy property-set fast-path. |
| src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionMultiTypeDispatcher.java | Overrides compound-assign emission to retain primitive/array fast paths. |
| src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java | Routes compound-assign tokens through new evaluateCompoundAssign helper-based path. |
| src/main/java/org/codehaus/groovy/classgen/Verifier.java | Skips final-variable reassignment checks for compound assigns marked as in-place via STC metadata. |
| src/main/java/groovy/transform/OperatorRename.java | Adds annotation members for *Assign renames. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2499 +/- ##
==================================================
+ Coverage 67.2264% 67.2449% +0.0185%
- Complexity 31984 32016 +32
==================================================
Files 1468 1468
Lines 123923 124054 +131
Branches 22251 22266 +15
==================================================
+ Hits 83309 83420 +111
- Misses 33433 33452 +19
- Partials 7181 7182 +1
🚀 New features to boost your workflow:
|
d228b36 to
a49310e
Compare
blackdrag
reviewed
Apr 29, 2026
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.
…ading (GEP-15)