File tree 2 files changed +26
-4
lines changed
compiler/src/dotty/tools/dotc/parsing 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,9 @@ object Scanners {
335
335
this .token = token
336
336
}
337
337
338
+ def isOperator =
339
+ token == IDENTIFIER && isOperatorPart(name(name.length - 1 ))
340
+
338
341
/** A leading symbolic or backquoted identifier is treated as an infix operator if
339
342
* - it does not follow a blank line, and
340
343
* - it is followed by at least one whitespace character and a
@@ -343,17 +346,17 @@ object Scanners {
343
346
*/
344
347
def isLeadingInfixOperator (inConditional : Boolean = true ) =
345
348
allowLeadingInfixOperators
346
- && ( token == BACKQUOTED_IDENT
347
- || token == IDENTIFIER && isOperatorPart(name(name.length - 1 )))
349
+ && (token == BACKQUOTED_IDENT || isOperator)
348
350
&& (isWhitespace(ch) || ch == LF )
349
351
&& ! pastBlankLine
350
352
&& {
351
353
val lookahead = LookaheadScanner ()
352
354
lookahead.allowLeadingInfixOperators = false
353
355
// force a NEWLINE a after current token if it is on its own line
354
356
lookahead.nextToken()
355
- canStartExprTokens.contains(lookahead.token)
356
- || lookahead.token == NEWLINE && canStartExprTokens.contains(lookahead.next.token)
357
+ (canStartExprTokens.contains(lookahead.token)
358
+ || lookahead.token == NEWLINE && canStartExprTokens.contains(lookahead.next.token)
359
+ ) && ! lookahead.isOperator
357
360
}
358
361
&& {
359
362
if migrateTo3 then
Original file line number Diff line number Diff line change
1
+ object HelloWorld {
2
+ def whileLoop : Int = {
3
+ var i = 0
4
+ var acc = 0
5
+ while (i < 3 ) {
6
+ var `i'` = 0
7
+ while (`i'` < 4 ) {
8
+ acc += (i * `i'`)
9
+ `i'` += 1
10
+ }
11
+ i += 1
12
+ }
13
+ acc
14
+ }
15
+
16
+ def main (args : Array [String ]): Unit = {
17
+ println(s " hello world: ${whileLoop}" )
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments