File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -1830,14 +1830,14 @@ object Parsers {
18301830 * the initially parsed (...) region?
18311831 */
18321832 def toBeContinued (altToken : Token ): Boolean =
1833- if in.isNewLine || migrateTo3 then
1834- false // a newline token means the expression is finished
1835- else if ! in.canStartStatTokens.contains(in.token)
1836- || in.isLeadingInfixOperator(inConditional = true )
1837- then
1838- true
1839- else
1840- followedByToken(altToken) // scan ahead to see whether we find a `then` or `do`
1833+ inline def canContinue =
1834+ ! in.canStartStatTokens.contains(in.token) // not statement, so take as continued expr
1835+ || followedByToken(altToken) // scan ahead to see whether we find a `then` or `do`
1836+
1837+ ! in.isNewLine // a newline token means the expression is finished
1838+ && ! migrateTo3 // old syntax
1839+ && canContinue
1840+ end toBeContinued
18411841
18421842 def condExpr (altToken : Token ): Tree =
18431843 val t : Tree =
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ object Test:
8282 x < 10
8383 do ()
8484
85+ def sign (x : Int ): Int =
86+ if (x > 0 ) 1
87+ else if (x < 0 ) - 1 // was: value - is not a member of Boolean
88+ else 0
89+ def lessPersuasively (x : Int ): Unit =
90+ while (x < 0 ) - 42 // was: value - is not a member of Boolean
91+ end Test
92+
8593class Test2 :
8694 self =>
8795 def foo (x : Int ) =
@@ -147,4 +155,4 @@ class Coder(words: List[String]):
147155end Coder
148156
149157object Test22 :
150- def foo : Int = 22
158+ def foo : Int = 22
You can’t perform that action at this time.
0 commit comments