Skip to content

Commit 5a87090

Browse files
committed
Fix rebase breakage and add a test
1 parent 8a872b6 commit 5a87090

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,13 +1280,14 @@ object Parsers {
12801280

12811281
def argumentStart(): Unit =
12821282
colonAtEOLOpt()
1283-
if in.isScala2CompatMode && in.token == NEWLINE && in.next.token == LBRACE then
1283+
if migrateTo3 && in.token == NEWLINE && in.next.token == LBRACE then
12841284
in.nextToken()
12851285
if in.indentWidth(in.offset) == in.currentRegion.indentWidth then
1286-
in.errorOrMigrationWarning(
1286+
ctx.errorOrMigrationWarning(
12871287
i"""This opening brace will start a new statement in Scala 3.
12881288
|It needs to be indented to the right to keep being treated as
1289-
|an argument to the previous expression.${rewriteNotice()}""")
1289+
|an argument to the previous expression.${rewriteNotice()}""",
1290+
in.sourcePos())
12901291
patch(source, Span(in.offset), " ")
12911292

12921293
def possibleTemplateStart(isNew: Boolean = false): Unit =

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ object Scanners {
438438
def isContinuingParens() =
439439
openParensTokens.contains(token)
440440
&& !pastBlankLine
441-
&& !isScala2CompatMode
441+
&& !migrateTo3
442442
&& !noindentSyntax
443443

444444
/** The indentation width of the given offset */

tests/pos/newline-braces.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ def f: Int => Int =
1414
{ (x: Int) =>
1515
x + 1
1616
}
17+
18+
val x =
19+
true && // newline inserted here but skipped because of trailing &&
20+
{
21+
val xyz = true
22+
xyz && false
23+
}

0 commit comments

Comments
 (0)