Skip to content

GROOVY-11985: Static method override on trait implementer ignored whe…#2529

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

GROOVY-11985: Static method override on trait implementer ignored whe…#2529
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy11985

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

…n called via this in trait body

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.1436%. Comparing base (a34df97) to head (1e0b4be).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2529        +/-   ##
==================================================
+ Coverage     68.1373%   68.1436%   +0.0063%     
- Complexity      32717      32722         +5     
==================================================
  Files            1499       1499                
  Lines          125162     125168         +6     
  Branches        22566      22568         +2     
==================================================
+ Hits            85282      85294        +12     
+ Misses          32388      32384         -4     
+ Partials         7492       7490         -2     
Files with missing lines Coverage Δ
...oovy/transform/trait/TraitReceiverTransformer.java 89.0173% <100.0000%> (+0.3946%) ⬆️

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

@eric-milles
Copy link
Copy Markdown
Member

This looks awfully familiar to the recent change to field reference. Was the dynamic marker the missing detail? Or was it more than that?

@eric-milles
Copy link
Copy Markdown
Member

eric-milles commented May 13, 2026

I was able to try this out yesterday (internet outage) and the change is in the spot that I would expect. The difficulty I have is reasoning about and explaining to others why "this.m(x)" can be rewritten to 3 -- or more depending on how you look at it -- different forms:

  • ($static$self or $self.getClass()).m(x)
  • (this or T$Trait$Helper).m($self or $static$self or $self.getClass(), x)
  • (this or $self or $static$self).m(x)

I did see that between Groovy 3 and Groovy 4, the behavior was change for private static methods. Then between Groovy 4 and 5 there was a change for the "override" or "cannot be replaced by trait method" case. I'm still on the fence about allowing dynamic dispatch so the seen trait method is not the one called in all cases.

@paulk-asert
Copy link
Copy Markdown
Contributor Author

paulk-asert commented May 13, 2026

@eric-milles I'll answer in the Jira issue to keep together with some other comments.

@testlens-app
Copy link
Copy Markdown

testlens-app Bot commented May 14, 2026

✅ All tests passed ✅

🏷️ Commit: 1e0b4be
▶️ Tests: 97721 executed
⚪️ Checks: 28/28 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