Skip to content

Scala parser: support parameterless methods, annotated methods, remove while/annotation fallbacks#7262

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

Scala parser: support parameterless methods, annotated methods, remove while/annotation fallbacks#7262
jkschneider wants to merge 1 commit intomainfrom
scala-parser-fixes

Conversation

@jkschneider
Copy link
Copy Markdown
Member

Summary

  • Parameterless methods (def name: Type = expr) now map to J.MethodDeclaration with OmitBraces marker on empty param container — printer omits ()
  • Annotated methods (@deprecated def ...) now map to J.MethodDeclaration with annotations extracted and synthetic def modifier carrying annotation-to-def spacing
  • Remove while loop fallback — while loops in method bodies now handled by block parser
  • Remove annotation fallback — simple annotations now work; complex annotations (with args) still have issues
  • Down from 7 → 3 remaining visitUnknown(dd) fallbacks: procedure syntax, nested braces, function type params

Test plan

  • 407 of 412 tests pass (5 failures: 3 complex annotations with args, 2 while body block whitespace)
  • Parameterless methods: def toString: String, def break: Unit round-trip correctly
  • Annotated methods: @deprecated def oldMethod(): Unit = {} round-trips correctly
  • Complex param types: Map[String, Any], Array[String] in method signatures work

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Apr 2, 2026
@jkschneider jkschneider force-pushed the scala-parser-fixes branch 4 times, most recently from 022f9d2 to 6b749e3 Compare April 2, 2026 21:47
…e while fallback

- Parameterless methods (def name: Type) now map to J.MethodDeclaration with
  OmitBraces marker on empty param container — printer omits ()
- Annotated methods (@deprecated def ...) now map to J.MethodDeclaration with
  annotations extracted and def-modifier carrying annotation-to-def spacing
- Remove while loop fallback — while loops in method bodies handled by parser
- Remove AppliedTypeTree fallback (already fixed in #7260)
- 3 remaining fallbacks: procedure syntax, nested braces, function type params
- 5 test failures: 3 complex annotations (with args), 2 while body block whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant