Draft
Conversation
The Scala 3 compiler uses two different AST representations for try/catch/finally: `Trees.Try` (typed/desugared) and `untpd.ParsedTry` (untyped/parsed). PR #7260 added handling for `Trees.Try` but `ParsedTry` was falling through to `visitUnknown` since it extends `Trees.Tree` directly and not `Trees.Try`. Add `visitParsedTry`/`visitParsedTryImpl` to handle `ParsedTry` by extracting cases from its `handler` (a `Match` tree) and mapping them to `J.Try` AST nodes. Update `ScalaPrinter` to use AST-stored spacing for catch block formatting.
Contributor
IMHO this might be some effect of some classpath lacking or similar. And therefore Scala Compiler failing to provide type attribution properly. |
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.
Summary
untpd.ParsedTryAST nodes inScalaTreeVisitor, which were falling through tovisitUnknownand producingJ.Unknowninstead ofJ.TryTrees.Try(typed) anduntpd.ParsedTry(untyped). PR Scala parser: add try/catch/finally, match, and fix complex parameter types #7260 handledTrees.TrybutParsedTryextendsTrees.Treedirectly, notTrees.Try, so it was missedScalaPrinterto use AST-stored spacing for catch block formatting instead of hardcoded whitespaceTest plan
ParsedTryTestwith cases for try/finally with throw and try/catch with Throwable (patterns that produceParsedTry)