Skip to content

Commit d2a5fc7

Browse files
committed
Accept soft modifiers separated by blank lines
This was handled inconsistently before. An identifier could be classified as a soft modifier even if followed by newlines but then the modifier parsing code would not skip the NEWLINES token. Now it does skip.
1 parent b7ab844 commit d2a5fc7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,7 @@ object Parsers {
28732873
val isAccessMod = accessModifierTokens contains in.token
28742874
val mods1 = addModifier(mods)
28752875
loop(if (isAccessMod) accessQualifierOpt(mods1) else mods1)
2876-
else if (in.token == NEWLINE && (mods.hasFlags || mods.hasAnnotations)) {
2876+
else if (in.isNewLine && (mods.hasFlags || mods.hasAnnotations)) {
28772877
in.nextToken()
28782878
loop(mods)
28792879
}

tests/pos/i11712.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
object Test:
2+
3+
def transparent = println("transparent method called")
4+
5+
transparent
6+
println()
7+
inline def f1 = 1
8+
9+
transparent
10+
inline def f2 = 2
11+
12+
transparent
13+
trait T1
14+
15+
transparent
16+
17+
inline def f3 = 3
18+
19+
transparent
20+
21+
trait T2

0 commit comments

Comments
 (0)