Skip to content

fix: accept additional intersection cast operands - #37

Merged
exKAZUu merged 1 commit into
mainfrom
fix/intersection-cast-operands
Oct 21, 2026
Merged

exKAZUu merged 1 commit into
mainfrom
fix/intersection-cast-operands

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

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 in grammar-orchard/tree-sitter-java-orchard#10 with 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#10 separately 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 to unary_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

  • Official JDK 27.0.1 compiled the eight-method intersection fixture and 17-method unary controls with no diagnostics.
  • Canonical CLI 9 generation, native/Wasm corpus: 162 cases passed; bun run verify passed with no code-gauge findings; 68 focused tests in 12 files passed; Rust unit and doc tests passed.
  • All 162 corpus cases passed 100 incremental fuzz iterations with up to 10 edits, recorded seed 5300980673173803960.
  • Actual published 8.0.2 reproduces the cast errors. Web API boundary checks validate six cast roles, eight method tags and six edit/undo states. Full trees, fields, spans and shipped captures match published 8.0.2 for 32 control programs, 240 whitespace cases and six existing CST/query controls.
  • Full PR CI passed, including browser, Rust, Linux and both macOS variants, and robustness fuzzing.

Notes

Postfix/cast precedence is a separate queued origin. The scoped control comparisons do not claim universal parser parity.

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>
@exKAZUu exKAZUu self-assigned this Oct 21, 2026
@exKAZUu
exKAZUu merged commit e6998f0 into main Oct 21, 2026
10 checks passed
@exKAZUu
exKAZUu deleted the fix/intersection-cast-operands branch October 21, 2026 23:49
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.

1 participant