File tree 2 files changed +17
-9
lines changed
compiler/src/dotty/tools/dotc/parsing
2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -1830,14 +1830,14 @@ object Parsers {
1830
1830
* the initially parsed (...) region?
1831
1831
*/
1832
1832
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
1841
1841
1842
1842
def condExpr (altToken : Token ): Tree =
1843
1843
val t : Tree =
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ object Test:
82
82
x < 10
83
83
do ()
84
84
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
+
85
93
class Test2 :
86
94
self =>
87
95
def foo (x : Int ) =
@@ -147,4 +155,4 @@ class Coder(words: List[String]):
147
155
end Coder
148
156
149
157
object Test22 :
150
- def foo : Int = 22
158
+ def foo : Int = 22
You can’t perform that action at this time.
0 commit comments