From d2a5fc77765242d3887d1cb688612089836e2f05 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 18 Apr 2022 10:29:43 +0200 Subject: [PATCH 1/2] 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. --- .../dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/pos/i11712.scala | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i11712.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 8fab2e4074b9..30a6d94726d9 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2873,7 +2873,7 @@ object Parsers { val isAccessMod = accessModifierTokens contains in.token val mods1 = addModifier(mods) loop(if (isAccessMod) accessQualifierOpt(mods1) else mods1) - else if (in.token == NEWLINE && (mods.hasFlags || mods.hasAnnotations)) { + else if (in.isNewLine && (mods.hasFlags || mods.hasAnnotations)) { in.nextToken() loop(mods) } diff --git a/tests/pos/i11712.scala b/tests/pos/i11712.scala new file mode 100644 index 000000000000..27fc1ef2771e --- /dev/null +++ b/tests/pos/i11712.scala @@ -0,0 +1,21 @@ +object Test: + + def transparent = println("transparent method called") + + transparent + println() + inline def f1 = 1 + + transparent + inline def f2 = 2 + + transparent + trait T1 + + transparent + + inline def f3 = 3 + + transparent + + trait T2 \ No newline at end of file From eb1e71f518ea35acffeef627a503de5c6bf697e7 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 18 Apr 2022 11:13:09 +0200 Subject: [PATCH 2/2] Fix syntax in Expr.scala ``` class Expr private object ``` now means the `private` modifier is for the following `object`, not the (invisible) constructor of `Expr`. --- library/src/scala/quoted/Expr.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index bf7922239314..996fe3ff8da2 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -4,7 +4,7 @@ package scala.quoted * * `Expr` has extension methods that are defined in `scala.quoted.Quotes`. */ -abstract class Expr[+T] private[scala] +abstract class Expr[+T] private[scala] () /** Constructors for expressions */ object Expr {