@@ -1278,6 +1278,17 @@ object Parsers {
12781278 if (in.token == COLONEOL ) in.nextToken()
12791279 }
12801280
1281+ def argumentStart (): Unit =
1282+ colonAtEOLOpt()
1283+ if in.isScala2CompatMode && in.isNewLine && in.next.token == LBRACE then
1284+ in.nextToken()
1285+ if in.indentWidth(in.offset) == in.currentRegion.indentWidth then
1286+ in.errorOrMigrationWarning(
1287+ i """ This opening brace will start a new statement in Scala 3.
1288+ |It needs to be indented to the right to keep being treated as
1289+ |an argument to the previous expression. ${rewriteNotice()}""" )
1290+ patch(source, Span (in.offset), " " )
1291+
12811292 def possibleTemplateStart (isNew : Boolean = false ): Unit =
12821293 in.observeColonEOL()
12831294 if in.token == COLONEOL then
@@ -1468,7 +1479,7 @@ object Parsers {
14681479 val refinedType : () => Tree = () => refinedTypeRest(withType())
14691480
14701481 def refinedTypeRest (t : Tree ): Tree = {
1471- colonAtEOLOpt ()
1482+ argumentStart ()
14721483 if (in.isNestedStart)
14731484 refinedTypeRest(atSpan(startOffset(t)) { RefinedTypeTree (rejectWildcardType(t), refinement()) })
14741485 else t
@@ -2222,7 +2233,7 @@ object Parsers {
22222233 }
22232234
22242235 def simpleExprRest (t : Tree , canApply : Boolean = true ): Tree = {
2225- if canApply then colonAtEOLOpt ()
2236+ if ( canApply) argumentStart ()
22262237 in.token match {
22272238 case DOT =>
22282239 in.nextToken()
@@ -2298,7 +2309,7 @@ object Parsers {
22982309 /** ArgumentExprss ::= {ArgumentExprs}
22992310 */
23002311 def argumentExprss (fn : Tree ): Tree = {
2301- colonAtEOLOpt ()
2312+ argumentStart ()
23022313 if (in.token == LPAREN || in.isNestedStart) argumentExprss(mkApply(fn, argumentExprs()))
23032314 else fn
23042315 }
@@ -3323,7 +3334,7 @@ object Parsers {
33233334 */
33243335 def selfInvocation (): Tree =
33253336 atSpan(accept(THIS )) {
3326- colonAtEOLOpt ()
3337+ argumentStart ()
33273338 argumentExprss(mkApply(Ident (nme.CONSTRUCTOR ), argumentExprs()))
33283339 }
33293340
0 commit comments