GROOVY-10355: restore binary reading of (name) +/- x and (name) in/as… - #2817
Conversation
5451ff0 to
af2b7b6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2817 +/- ##
==================================================
+ Coverage 70.1846% 70.2571% +0.0726%
- Complexity 35846 36248 +402
==================================================
Files 1562 1569 +7
Lines 132542 133706 +1164
Branches 24379 24632 +253
==================================================
+ Hits 93024 93938 +914
- Misses 31109 31255 +146
- Partials 8409 8513 +104
🚀 New features to boost your workflow:
|
96b0192 to
cd6fa5e
Compare
|
A couple of things I wasn’t sure about — I may well have missed the intended scope.
On master the parenthesized command forms don’t compile. After the rewrite they compile, but with the inverted meaning. Would it be reasonable to peel
Source positions. Inner nodes from
Comments / tests. The text says “lowercase-initial”; the check is |
… x (design sketch) A parenthesized bare name whose final segment starts lowercase is by convention a value, not a class, so a cast mis-parse of the ambiguous shapes is rebuilt in AstBuilder as the binary expression the syntax visually suggests, preserving textual left-to-right grouping across precedence levels. The binary-only keywords in/as captured as cast operand identifiers are restored to their relational reading for any capitalization. Unresolvable bare-name cast types now carry a hint explaining the ambiguity and the ((name)) workaround. The grammar is unchanged: a predicate-gated castExprAlt is not viable because adaptive prediction under the me.sunlan antlr4 fork only consults semantic predicates when a decision conflict is registered, which this decision never produces, so the predicate would only fire as a parse-time FailedPredicateException.
cd6fa5e to
515d6f7
Compare
✅ All tests passed ✅🏷️ Commit: 515d6f7 Learn more about TestLens at testlens.app/docs. |
|
@daniellansun Response to your questions in the Jira ticket. |
| * The value is the complete hint text; this visitor attaches no meaning to it. | ||
| */ | ||
| @Internal | ||
| public static final String CAST_RESOLVE_HINT = "_CAST_RESOLVE_HINT"; |
There was a problem hiding this comment.
It looks better that way, but I am still not happy about this being such a specialized mechanism for just one thing, but spanning so much across packages and compilation phases. If we made this a more general mechanism and for example call it "_RESOLVE_HINT", then it would look better, but is it better? If it stays a single use case, then probably not. So I guess in combination with @internal this is ok. We can still change it later if we really want to.
… x (design sketch)
A parenthesized bare name whose final segment starts lowercase is by convention a value, not a class, so a cast mis-parse of the ambiguous shapes is rebuilt in AstBuilder as the binary expression the syntax visually suggests, preserving textual left-to-right grouping across precedence levels. The binary-only keywords in/as captured as cast operand identifiers are restored to their relational reading for any capitalization. Unresolvable bare-name cast types now carry a hint explaining the ambiguity and the ((name)) workaround.
The grammar is unchanged: a predicate-gated castExprAlt is not viable because adaptive prediction under the me.sunlan antlr4 fork only consults semantic predicates when a decision conflict is registered, which this decision never produces, so the predicate would only fire as a parse-time FailedPredicateException.