Skip to content

GROOVY-12093: Static method override on trait implementer ignored whe…#2618

Open
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12093
Open

GROOVY-12093: Static method override on trait implementer ignored whe…#2618
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12093

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

…n called via this in trait body (cont'd)

@codecov-commenter

codecov-commenter commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.4528%. Comparing base (40c6203) to head (19fa2a8).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...groovy/transform/trait/TraitASTTransformation.java 86.7924% 2 Missing and 5 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2618        +/-   ##
==================================================
- Coverage     68.4541%   68.4528%   -0.0013%     
- Complexity      33505      33521        +16     
==================================================
  Files            1518       1518                
  Lines          127107     127162        +55     
  Branches        23065      23079        +14     
==================================================
+ Hits            87010      87046        +36     
- Misses          32371      32380         +9     
- Partials         7726       7736        +10     
Files with missing lines Coverage Δ
...oovy/transform/trait/TraitReceiverTransformer.java 89.1429% <100.0000%> (+0.1255%) ⬆️
...groovy/transform/trait/TraitASTTransformation.java 90.5405% <86.7924%> (-0.6267%) ⬇️

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements GROOVY-12093 by introducing an @Anchored marker for trait static methods to opt out of per-implementer override-style dispatch and (by default) promote those methods onto the generated trait interface, plus adds comprehensive tests covering the resulting dispatch matrix.

Changes:

  • Add groovy.transform.Anchored annotation with inInterface opt-out.
  • Update trait static dispatch rewriting to treat @Anchored statics as declarer-bound (helper/interface-static flavor).
  • Extend TraitASTTransformation to validate @Anchored usage and generate interface forwarders; add new regression/behavior tests.

Reviewed changes

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

Show a summary per file
File Description
src/main/java/groovy/transform/Anchored.java Adds the public @Anchored marker annotation and its inInterface option.
src/main/java/org/codehaus/groovy/transform/trait/TraitReceiverTransformer.java Skips implementer-routing for @Anchored trait statics during receiver rewriting.
src/main/java/org/codehaus/groovy/transform/trait/TraitASTTransformation.java Validates @Anchored usage and generates interface forwarders for anchored statics.
src/test/groovy/org/codehaus/groovy/transform/traitx/TraitStaticDispatchMatrix.groovy Adds an executable behavior matrix covering trait/static dispatch scenarios (incl. anchored rows).
src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy12093.groovy Adds targeted tests for @Anchored semantics, STC interactions, and validation errors.

@testlens-app

testlens-app Bot commented Jun 23, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

⚠️ TestLens detected flakiness ⚠️

Test Summary

Build and test / lts (17, windows-latest, 1) > :test

Test Runs
GenericsSTCTest > testReturnTypeInferenceWithMethodGenerics18() ❌ ✅
GenericsSTCTest > testReturnTypeInferenceWithMethodGenerics18a() ❌ ✅
GenericsStaticCompileTest > testReturnTypeInferenceWithMethodGenerics18() ❌ ✅
GenericsStaticCompileTest > testReturnTypeInferenceWithMethodGenerics18a() ❌ ✅

🏷️ Commit: 19fa2a8
▶️ Tests: 18675 executed
⚪️ Checks: 30/30 completed


Learn more about TestLens at testlens.app.

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