Repository navigation
GROOVY-12520: super.x calls isX() when the class overrides isX() - #3046
Conversation
When a class declares both isX() and getX(), the property x is read through isX() (GROOVY-10133), also through super. For super usage the getter of a method the subclass overrides is the MOP method super$N$isX, and the check that keeps isX() over getX() only accepted names starting with "is", so getX() replaced it: in a class that overrides isX() or declares a boolean property x, super.x called getX() in dynamic Groovy and under @TypeChecked. The check now looks past the MOP prefix. 4.0.33 called isX(); the order in which the accessors are indexed changed in 5.0.0.
✅ All tests passed ✅Test SummaryTip Inspect all details with the TestLens CLI: Build and test / lts (17, ubuntu-latest) > :test
🏷️ Commit: 15cfcd7 Test FailuresParallelCollectionTest > testEachParallelRunsConcurrently() (:test in Build and test / lts (17, ubuntu-latest) | Attempt 1/2)Learn more about TestLens at testlens.app/docs. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3046 +/- ##
==================================================
+ Coverage 73.6073% 73.6156% +0.0083%
- Complexity 42312 42318 +6
==================================================
Files 1657 1657
Lines 145620 145624 +4
Branches 27466 27467 +1
==================================================
+ Hits 107187 107202 +15
+ Misses 28469 28461 -8
+ Partials 9964 9961 -3
🚀 New features to boost your workflow:
|
|
The two failed jobs are unrelated to this change:
Could someone with the rights rerun the two failed jobs? |
daniellansun
left a comment
There was a problem hiding this comment.
Nice, focused fix.
For super usage the getter of an overridden isX() is the MOP method super$N$isX, so the old startsWith("is") check let getX() win. Looking past the super$N$ prefix restores the GROOVY-10133 preference and matches 4.0.33 / this.x / @CompileStatic.
Tests look thorough (override vs boolean property, three modes, closures). +1, and I agree it is worth backporting to GROOVY_5_0_X and GROOVY_6_0_X.
|
Merged, and a added one more test and a doc tweak separately. |
When a superclass declares both
isX()andgetX(), the propertyxis read throughisX()(GROOVY-10133). In a class that overridesisX()or declares aboolean xproperty,super.xcalledgetX()instead, in dynamic Groovy and under@TypeChecked. It now callsisX(), as@CompileStatic,this.xand Groovy 4.0.33 do. This is a regression in 5.0.0.How
For
superusage, the getter of a method the subclass overrides is the MOP methodsuper$N$isX. The check that keepsisX()overgetX()only accepted names starting withis, sogetX()replaced it. The check now looks past the MOP prefix. The order in which the accessors are indexed changed in 5.0.0, which is why 4.0.33 was not affected.Tests
bugs.Groovy10133, for an overridingisX()and for aboolean xproperty, in all three modes, and in a closure in dynamic Groovy and under@TypeChecked. They fail without the change. 14,936 tests in thegroovy,gls,bugs,org.codehaus.groovy.classgen,transform,runtime,reflection,vmplugin,controlandastpackages and the stub generator tests pass.groovy-contracts,groovy-typecheckers,groovy-ginq,groovy-macro-library,groovy-json,groovy-xmlandgroovy-templatespass their tests, and every subproject compiles its main and test sources. The Checkstyle and CodeNarc gates pass.Being a regression in 5.0.0, this may be worth backporting to
GROOVY_5_0_XandGROOVY_6_0_X.