Repository navigation
GROOVY-12441: fix ClassCastException for explicit this/super inside closures under @CompileStatic - #3068
GROOVY-12441: fix ClassCastException for explicit this/super inside closures under @CompileStatic#3068daniellansun wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3068 +/- ##
==================================================
+ Coverage 74.5006% 74.5095% +0.0089%
- Complexity 44947 44991 +44
==================================================
Files 1703 1704 +1
Lines 152337 152453 +116
Branches 29187 29223 +36
==================================================
+ Hits 113492 113592 +100
- Misses 28413 28414 +1
- Partials 10432 10447 +15
🚀 New features to boost your workflow:
|
|
Friendly ping: CI is green and this is ready for review. If there are no objections, I plan to merge it this weekend. Thanks! |
|
I agree something is needed here beyond documentation: I also tried the other obvious fix, making SC resolve an untyped On Jochen's point about the amount of visitor code: the same four hook points work with a Happy to share the patch if useful. Separately, a Javadoc on |
|
@paulk-asert Thank you — that analysis was exactly what we needed. Tip
Locally: |
VariableExpression.THIS_EXPRESSION and SUPER_EXPRESSION are process-wide singletons. Static type checking will not store an inferred type on them, so static compilation falls back to the class currently being generated. Inside a closure that class is the closure, and the enclosing instance is cast to it. Before type checking, replace each use with a fresh VariableExpression so the existing per-node inference applies inside and outside closures.
Exercise the statement, expression, and sentinel-copy paths that static compilation of ordinary closures does not reach, including null children and both sides of the method-reference receiver choice.
17ee5d3 to
a791aac
Compare
✅ All tests passed ✅🏷️ Commit: a791aac Learn more about TestLens at testlens.app/docs. |
|
Ping @paulk-asert ;-) |
https://issues.apache.org/jira/browse/GROOVY-12441