@@ -1276,10 +1276,17 @@ object Parsers {
12761276 if (in.token == COLONEOL ) in.nextToken()
12771277 }
12781278
1279- def possibleBracesStart (): Unit = {
1279+ def argumentStart (): Unit =
12801280 colonAtEOLOpt()
1281- newLineOptWhenFollowedBy(LBRACE )
1282- }
1281+ if migrateTo3 && in.token == NEWLINE && in.next.token == LBRACE then
1282+ in.nextToken()
1283+ if in.indentWidth(in.offset) == in.currentRegion.indentWidth then
1284+ ctx.errorOrMigrationWarning(
1285+ i """ This opening brace will start a new statement in Scala 3.
1286+ |It needs to be indented to the right to keep being treated as
1287+ |an argument to the previous expression. ${rewriteNotice()}""" ,
1288+ in.sourcePos())
1289+ patch(source, Span (in.offset), " " )
12831290
12841291 def possibleTemplateStart (isNew : Boolean = false ): Unit =
12851292 in.observeColonEOL()
@@ -1509,7 +1516,7 @@ object Parsers {
15091516 val refinedType : () => Tree = () => refinedTypeRest(withType())
15101517
15111518 def refinedTypeRest (t : Tree ): Tree = {
1512- possibleBracesStart ()
1519+ argumentStart ()
15131520 if (in.isNestedStart)
15141521 refinedTypeRest(atSpan(startOffset(t)) { RefinedTypeTree (rejectWildcardType(t), refinement()) })
15151522 else t
@@ -2265,7 +2272,7 @@ object Parsers {
22652272 }
22662273
22672274 def simpleExprRest (t : Tree , canApply : Boolean = true ): Tree = {
2268- if (canApply) possibleBracesStart ()
2275+ if (canApply) argumentStart ()
22692276 in.token match {
22702277 case DOT =>
22712278 in.nextToken()
@@ -2338,7 +2345,7 @@ object Parsers {
23382345 /** ArgumentExprss ::= {ArgumentExprs}
23392346 */
23402347 def argumentExprss (fn : Tree ): Tree = {
2341- possibleBracesStart ()
2348+ argumentStart ()
23422349 if (in.token == LPAREN || in.isNestedStart) argumentExprss(mkApply(fn, argumentExprs()))
23432350 else fn
23442351 }
@@ -2831,7 +2838,7 @@ object Parsers {
28312838 }
28322839
28332840 def annotations (skipNewLines : Boolean = false ): List [Tree ] = {
2834- if (skipNewLines) newLineOptWhenFollowedBy (AT )
2841+ if (skipNewLines) newLinesOptWhenFollowedBy (AT )
28352842 if (in.token == AT ) annot() :: annotations(skipNewLines)
28362843 else Nil
28372844 }
@@ -3358,7 +3365,7 @@ object Parsers {
33583365 */
33593366 def selfInvocation (): Tree =
33603367 atSpan(accept(THIS )) {
3361- possibleBracesStart ()
3368+ argumentStart ()
33623369 argumentExprss(mkApply(Ident (nme.CONSTRUCTOR ), argumentExprs()))
33633370 }
33643371
0 commit comments