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 Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.1662%. Comparing base (09e9122) to head (9115a3d).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2529        +/-   ##
==================================================
- Coverage     68.1761%   68.1662%   -0.0099%     
- Complexity      32715      32720         +5     
==================================================
  Files            1498       1499         +1     
  Lines          125079     125109        +30     
  Branches        22542      22551         +9     
==================================================
+ Hits            85274      85282         +8     
- Misses          32317      32339        +22     
  Partials         7488       7488                
Files with missing lines Coverage Δ
...oovy/transform/trait/TraitReceiverTransformer.java 89.0173% <100.0000%> (+0.3946%) ⬆️

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

@testlens-app
Copy link
Copy Markdown

testlens-app Bot commented May 11, 2026

✅ All tests passed ✅

🏷️ Commit: 9115a3d
▶️ Tests: 0 executed
⚪️ Checks: 28/28 completed


Learn more about TestLens at testlens.app.

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

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