@@ -97,6 +97,9 @@ object Parsers {
9797 private val InCase : Region => Region = Scanners .InCase (_)
9898 private val InCond : Region => Region = Scanners .InParens (LPAREN , _)
9999 private val InFor : Region => Region = Scanners .InBraces (_)
100+ private val InOldCond : Region => Region = // old-style Cond to allow indent when InParens, see #22608
101+ case p : Scanners .InParens => Scanners .Indented (p.indentWidth, p.prefix, p)
102+ case r => r
100103
101104 abstract class ParserCommon (val source : SourceFile )(using Context ) {
102105
@@ -2129,25 +2132,25 @@ object Parsers {
21292132 def condExpr (altToken : Token ): Tree =
21302133 val t : Tree =
21312134 if in.token == LPAREN then
2132- var t : Tree = atSpan(in.offset):
2133- makeTupleOrParens(inParensWithCommas(commaSeparated(exprInParens)))
2134- if in.token != altToken then
2135- if toBeContinued(altToken) then
2136- t = inSepRegion(InCond ) {
2135+ inSepRegion(InOldCond ): // allow inferred NEWLINE for observeIndented below
2136+ atSpan(in.offset):
2137+ makeTupleOrParens(inParensWithCommas(commaSeparated(exprInParens)))
2138+ .pipe: t =>
2139+ if in.token == altToken then t
2140+ else if toBeContinued(altToken) then
2141+ inSepRegion(InCond ):
21372142 expr1Rest(
21382143 postfixExprRest(
21392144 simpleExprRest(t, Location .ElseWhere ),
21402145 Location .ElseWhere ),
21412146 Location .ElseWhere )
2142- }
21432147 else
21442148 if rewriteToNewSyntax(t.span) then
2145- dropParensOrBraces(t.span.start, s " ${ tokenString(altToken)} " )
2149+ dropParensOrBraces(t.span.start, tokenString(altToken))
21462150 in.observeIndented()
21472151 return t
2148- t
21492152 else if in.isNestedStart then
2150- try expr() finally newLinesOpt()
2153+ expr().tap(_ => newLinesOpt() )
21512154 else
21522155 inSepRegion(InCond )(expr())
21532156 if rewriteToOldSyntax(t.span.startPos) then revertToParens(t)
0 commit comments