Skip to content

Scala: close parser gaps for Super, ForYield, Alternative, and other AST nodes#7398

Open
jkschneider wants to merge 1 commit intomainfrom
worktree-scala-fixes
Open

Scala: close parser gaps for Super, ForYield, Alternative, and other AST nodes#7398
jkschneider wants to merge 1 commit intomainfrom
worktree-scala-fixes

Conversation

@jkschneider
Copy link
Copy Markdown
Member

Summary

  • Adds visitors for previously-unmapped dotty AST nodes (Super, Alternative, SingletonTypeTree, RefinedTypeTree, Annotated, MacroTree, ExtMethods, ForYield) so real-world Scala sources with these constructs no longer fail to parse.
  • Extends visitForDo to handle multi-generator, guarded, and destructured forms via source preservation.
  • Adds a preserve-source fallback at the end of visitApply for forms like super(args)/this(args) that the existing dispatch didn't cover.
  • Tightens compound-assign detection in visitInfixOp so user-defined operators like ===, =:=, <:<, := correctly route to infix method calls instead of being mis-treated as compound assignments.

The preserve-as-text mappings follow the existing pattern used by visitBind, visitInterpolatedString, visitTypeAlias, etc. Proper S-types for these constructs remain as follow-up work (per rewrite-scala/CLAUDE.md guidance).

Test plan

  • Added regression tests: SuperTest, TypeApplyTest, InfixOpTest, AlternativePatternTest, SingletonTypeTreeTest, RefinedTypeTreeTest, AnnotatedExprTest, ForYieldTest, ComplexForDoTest
  • ./gradlew :rewrite-scala:test passes

Fixes ScalaParser gaps surfaced by real-world parse testing. Adds visitors
for Trees.Super, Trees.Alternative, Trees.SingletonTypeTree, Trees.RefinedTypeTree,
Trees.Annotated, untpd.MacroTree, untpd.ExtMethods, and untpd.ForYield, plus
fallbacks for multi-generator/guarded ForDo and unrecognized Apply forms.
Tightens compound-assign detection so user-defined operators like ===, =:=,
and := route to infix method calls instead of failing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants