Repository navigation
fix: accept additional intersection cast operands - #37
Merged
Merged
Conversation
Parse nested casts, complement expressions and switch expressions as intersection-cast operands while preserving public unary query fields. Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Valid Java intersection casts such as
(Object & Serializable) ~value, a nested cast, or a switch operand produce parser errors. This addresses the operand gap identified ingrammar-orchard/tree-sitter-java-orchard#10with compiler-checked examples.Requirements
required: Improve the forked grammar repositories, excluding CSS and Markdown, as much as possible; backward compatibility may be ignored.
required: Review fork issues and major upstream issues, PRs and recent commits; check target PRs for duplicates and use a dedicated PR from latest main for each eligible origin.
required: Run review-booster and complete-pr concurrently, then release the changes, and continue the remaining eligible items.
required: Preserve the observable type/value and operator/operand fields used by parser queries.
chosen: Address the intersection-cast operand defect from
grammar-orchard/tree-sitter-java-orchard#10separately from the queued postfix/cast precedence defect, so each origin stays independently reviewable.chosen: Share complement parsing through a hidden rule aliased to unary_expression, preserving its existing public fields and left associativity; the verified defect requires additional intersection operands, not a global associativity change.
chosen: Preserve the existing single-cast syntax and the binary interpretation of (A & B) + value and (A & B) - value, which the compiler-checked controls exercise.
Customer Summary
Intersection casts accept nested casts, logical and bitwise complements, and switch expressions. Queries retain the existing cast type/value and unary operator/operand fields.
Technical Summary
Extend the intersection-cast value alternatives and share
!/~parsing through a hidden rule aliased tounary_expression. Keep current unary associativity and the existing single-cast branch. Regenerate the native parser; the public node schema and shipped queries are unchanged. A corpus fixture checks complete declarations and disambiguation, while an API test checks field-based queries on the alias and ordinary unary expressions.Testing
bun run verifypassed with no code-gauge findings; 68 focused tests in 12 files passed; Rust unit and doc tests passed.Notes
Postfix/cast precedence is a separate queued origin. The scoped control comparisons do not claim universal parser parity.