Skip to content

GROOVY-10355: restore binary reading of (name) +/- x and (name) in/as… - #2817

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

GROOVY-10355: restore binary reading of (name) +/- x and (name) in/as…#2817
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy10355

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

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

@paulk-asert
paulk-asert force-pushed the groovy10355 branch 3 times, most recently from 5451ff0 to af2b7b6 Compare August 18, 2026 23:50
@codecov-commenter

codecov-commenter commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.1908%. Comparing base (55dcfb9) to head (cd6fa5e).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...va/org/apache/groovy/parser/antlr4/AstBuilder.java 74.6032% 16 Missing and 16 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2817        +/-   ##
==================================================
+ Coverage     70.1846%   70.1908%   +0.0062%     
- Complexity      35846      35923        +77     
==================================================
  Files            1562       1563         +1     
  Lines          132542     132667       +125     
  Branches        24379      24424        +45     
==================================================
+ Hits            93024      93120        +96     
- Misses          31109      31123        +14     
- Partials         8409       8424        +15     
Files with missing lines Coverage Δ
...va/org/codehaus/groovy/control/ResolveVisitor.java 90.2948% <100.0000%> (+0.0119%) ⬆️
...va/org/apache/groovy/parser/antlr4/AstBuilder.java 86.8293% <74.6032%> (-0.6921%) ⬇️

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

* could equally be read as an operator continuation of a parenthesized value expression,
* so that later resolution failures can explain the ambiguity (GROOVY-10355).
*/
public static final String AMBIGUOUS_BARE_NAME_CAST = "_AMBIGUOUS_BARE_NAME_CAST";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we move that constant to a different place? I think ResolveVisitor should not reference AstBuilder or any antlr4 class if we can avoid that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inverted the relationship.

@testlens-app

This comment has been minimized.

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