nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: scalameta/scalameta
Pull request #3089 (2023-02-21 15:29:30)

ScalametaParser: fix parameter by-name logic
It was introduced in #3084 by mistake.


Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
index 59acd2048..9736fbd96 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
@@ -3143,9 +3143,9 @@ class ScalametaParser(input: Input)(implicit dialect: Dialect) { parser =>
                 val tpt = paramType()
                 if (tpt.is[Type.ByName]) {
                   def mayNotBeByName(mod: Mod) =
-                    syntaxError(s"$mod parameters may not be call-by-name", at = name)
+                    syntaxError(s"`$mod' parameters may not be call-by-name", at = name)
                   val isLocalToThis: Boolean =
-                    ownerIsCase || varOrVarParamMod.isEmpty || mods.exists {
+                    (!ownerIsCase && varOrVarParamMod.isEmpty) || mods.exists {
                       case Mod.Private(_: Term.This) => true; case _ => false
                     }
                   val badMod =


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/ModSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/ModSuite.scala
index 98f94fc9f..d16d1e2f8 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/ModSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/ModSuite.scala
@@ -800,4 +800,38 @@ class ModSuite extends ParseSuite {
     assert(actual.contains(expected), actual)
   }
 
+  test("by-name parameter: class with val") {
+    val actual = interceptParseError("class A(val b: => B)")
+    val expected =
+      s"""|error: `val' parameters may not be call-by-name
+          |class A(val b: => B)
+          |            ^""".stripMargin
+    assert(actual.contains(expected), actual)
+  }
+
+  test("by-name parameter: class with private[this] val") {
+    assertNoDiff(
+      templStat("class A(private[this] val b: => B)").syntax,
+      "class A(private[this] val b: => B)"
+    )
+  }
+
+  test("by-name parameter: case class with val") {
+    val actual = interceptParseError("case class A(val b: => B)")
+    val expected =
+      s"""|error: `val' parameters may not be call-by-name
+          |case class A(val b: => B)
+          |                 ^""".stripMargin
+    assert(actual.contains(expected), actual)
+  }
+
+  test("by-name parameter: class with implicit val") {
+    val actual = interceptParseError("class A(implicit val b: => B)")
+    val expected =
+      s"""|error: `val' parameters may not be call-by-name
+          |class A(implicit val b: => B)
+          |                     ^""".stripMargin
+    assert(actual.contains(expected), actual)
+  }
+
 }
Repository: scalameta/scalameta
Pull request #3202 (2023-06-27 16:28:25)

ScannerTokens: allow top-level `case`
For #3045.


Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
index 95521ec45..8bba883c2 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
@@ -494,6 +494,8 @@ final class ScannerTokens(val tokens: Tokens)(implicit dialect: Dialect) {
                 case _ => !next.isClassOrObject
               }) =>
             expr() :: sepRegions
+          // `case` is at top-level (likely quasiquote)
+          case Nil if prevPos == 0 && !next.isClassOrObject => expr() :: Nil
           case xs => xs
         })
       case _: KwFinally =>


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/PatSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/PatSuite.scala
index ab35dd293..b03221d38 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/PatSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/PatSuite.scala
@@ -16,6 +16,8 @@ class PatSuite extends ParseSuite {
     assertTree(patternTyp(expr))(tree)
   }
 
+  implicit def caseParser(code: String, dialect: Dialect): Case = super.parseCase(code)(dialect)
+
   test("_") {
     val Wildcard() = pat("_")
   }
@@ -263,4 +265,19 @@ class PatSuite extends ParseSuite {
     }
   }
 
+  test("case: at top level") {
+    val code =
+      """|case foo
+         |  if true =>
+         |  List(bar)
+         |""".stripMargin
+    checkTree(parseCase(code)) {
+      Case(
+        Pat.Var(Term.Name("foo")),
+        Some(Lit.Boolean(true)),
+        Term.Apply(Term.Name("List"), List(Term.Name("bar")))
+      )
+    }
+  }
+
 }
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/TermSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/TermSuite.scala
index 6339dfaac..0dd2073d8 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/TermSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/TermSuite.scala
@@ -1642,4 +1642,29 @@ class TermSuite extends ParseSuite {
     runTestAssert[Stat](codeOnSameLine, Some(syntaxOnSameLine))(treeOnSameLine)
   }
 
+  test("case: inside partial function") {
+    runTestAssert[Term](
+      """|{
+         |  case foo
+         |    if true =>
+         |    List(bar)
+         |}
+         |""".stripMargin,
+      Some(
+        """|{
+           |  case foo if true =>
+           |    List(bar)
+           |}""".stripMargin
+      )
+    )(
+      Term.PartialFunction(
+        Case(
+          Pat.Var(Term.Name("foo")),
+          Some(Lit.Boolean(true)),
+          Term.Apply(Term.Name("List"), List(Term.Name("bar")))
+        ) :: Nil
+      )
+    )
+  }
+
 }
Repository: scalameta/scalameta
Pull request #3341 (2023-09-13 16:56:45)

sbt-shading: use the released 2.1.3 version


Patch:
diff --git a/project/plugins.sbt b/project/plugins.sbt
index fd9bfe20b..742fa21a7 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -33,4 +33,4 @@ addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.14")
 
 addSbtPlugin("io.chrisdavenport" %% "sbt-npm-package" % "0.1.2")
 
-addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.3+9-9143b95e-SNAPSHOT")
+addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.1.3")


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/tokenizers/TokenizerSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/tokenizers/TokenizerSuite.scala
index c8af84333..4c4ea1ee8 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/tokenizers/TokenizerSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/tokenizers/TokenizerSuite.scala
@@ -1166,4 +1166,11 @@ class TokenizerSuite extends BaseTokenizerSuite {
       ("raw\"\"\"\\$host\\$share\\\"\"\"").tokenize.get
 
   }
+
+  test("#3328") {
+    val code = "val \\uD835\\uDF11: Double"
+    val res = dialects.Scala212(code).tokenize
+    assertEquals(res.toEither.left.get.message, "illegal character '\\ud835'")
+  }
+
 }
Repository: scalameta/scalameta
Pull request #3373 (2023-10-25 15:14:57)

Fix FuncParamClause not adding parentheses for Type.Function
Before:

```scala
q"def f: (B => B) => A".syntax
// "def f: B => B => A"
```

After:

```scala
q"def f: (B => B) => A".syntax
// "def f: (B => B) => A"
```

See the added test for more examples. Other cases are welcome as I might have missed something



Patch:
diff --git a/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeSyntax.scala b/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeSyntax.scala
index a6720d21c..214b25f83 100644
--- a/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeSyntax.scala
+++ b/scalameta/trees/shared/src/main/scala/scala/meta/internal/prettyprinters/TreeSyntax.scala
@@ -582,7 +582,9 @@ object TreeSyntax {
       case t: Type.FuncParamClause =>
         t.values match {
           case arg :: Nil if (arg match {
-                case _: Type.Tuple | _: Type.ByName | _: Type.FunctionParamOrArg => false
+                case _: Type.Tuple | _: Type.ByName | _: Type.FunctionParamOrArg |
+                    _: Type.Function =>
+                  false
                 case _ => true
               }) =>
             s(arg)


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala
index abc2c0c8d..957921513 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala
@@ -1304,6 +1304,17 @@ class SyntacticSuite extends scala.meta.tests.parsers.ParseSuite {
     checkStat("list reduce (_.a.b.c + _.d.e.f)")(q"list reduce (_.a.b.c + _.d.e.f)")
     checkStat("list reduce (_.a(foo) + _.b(bar))")(q"list reduce (_.a(foo) + _.b(bar))")
   }
+  test("parentheses on function param clauses") {
+    List(
+      "def f: (B => B) => A" -> q"def f: (B => B) => A",
+      "def f: B => B => A" -> q"def f: B => B => A",
+      "def f: B => A" -> q"def f: B => A",
+      "def f: (B => B) => A => A" -> q"def f: (B => B) => A => A",
+      "def f: (B => B) => (A => A) => A" -> q"def f: (B => B) => (A => A) => A"
+    ).foreach { case (code, expected) =>
+      checkStat(code, code)(expected)
+    }
+  }
 
   test("#1864 Terms with leading numerics are backquoted") {
     checkStat("`123foo`")(Term.Name("123foo"))
Repository: scalameta/scalameta
Pull request #3424 (2023-12-30 12:04:05)

Fix typo in error message


Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
index 39263f9f1..982a9e170 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
@@ -3705,7 +3705,7 @@ class ScalametaParser(input: Input)(implicit dialect: Dialect) { parser =>
         case name: Term.Name =>
           Decl.Given(mods, name, paramClauseGroup, decltype)
         case _ =>
-          syntaxError("abstract givens cannot be annonymous", at = sigName.pos)
+          syntaxError("abstract givens cannot be anonymous", at = sigName.pos)
       }
     }
   }


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/GivenUsingSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/GivenUsingSuite.scala
index 00ac271ff..185736c30 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/GivenUsingSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/GivenUsingSuite.scala
@@ -802,15 +802,15 @@ class GivenUsingSuite extends BaseDottySuite {
   test("abstract-given-anonymous") {
     runTestError(
       "given Ord[Int]",
-      "abstract givens cannot be annonymous"
+      "abstract givens cannot be anonymous"
     )
     runTestError(
       "given [T](using ord: Ord[T]): Ord[Set[T]]",
-      "abstract givens cannot be annonymous"
+      "abstract givens cannot be anonymous"
     )
     runTestError(
       "given (using Ord[String]): Ord[Int]",
-      "abstract givens cannot be annonymous"
+      "abstract givens cannot be anonymous"
     )
   }
Repository: scalameta/scalameta
Pull request #3487 (2024-01-13 15:10:29)

InternalTrees: add extension withOriginRecursive


Patch:
diff --git a/scalameta/transversers/shared/src/main/scala/scala/meta/transversers/Api.scala b/scalameta/transversers/shared/src/main/scala/scala/meta/transversers/Api.scala
index 2e83ce24f..4c1321a9a 100644
--- a/scalameta/transversers/shared/src/main/scala/scala/meta/transversers/Api.scala
+++ b/scalameta/transversers/shared/src/main/scala/scala/meta/transversers/Api.scala
@@ -37,6 +37,11 @@ private[meta] trait Api {
       buf.toList
     }
   }
+
+  implicit class XtensionTreeLike[T <: Tree](tree: T) {
+    private[meta] def withOriginRecursive(origin: trees.Origin): T =
+      tree.transform { case t: Tree => t.withOrigin(origin) }.asInstanceOf[T]
+  }
 }
 
 private[meta] trait Aliases {


Test patch:
diff --git a/tests/jvm/src/test/scala-2.13/scala/meta/tests/testkit/prettyprinters/PrettyPrinterSuite.scala b/tests/jvm/src/test/scala-2.13/scala/meta/tests/testkit/prettyprinters/PrettyPrinterSuite.scala
index d49ae6fcc..c443742ae 100644
--- a/tests/jvm/src/test/scala-2.13/scala/meta/tests/testkit/prettyprinters/PrettyPrinterSuite.scala
+++ b/tests/jvm/src/test/scala-2.13/scala/meta/tests/testkit/prettyprinters/PrettyPrinterSuite.scala
@@ -10,13 +10,7 @@ import munit.FunSuite
 
 class PrettyPrinterSuite extends FunSuite {
   implicit class XtensionResetOrigin[T <: Tree](tree: T) {
-    def resetAllOrigins: T = {
-      tree
-        .transform { case tree: Tree =>
-          tree.withOrigin(Origin.None)
-        }
-        .asInstanceOf[T]
-    }
+    def resetAllOrigins: T = tree.withOriginRecursive(Origin.None)
   }
 
   def checkOk(code: String): Unit = {
diff --git a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala
index f6ad6ac9c..86efc2427 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/SyntacticSuite.scala
@@ -25,9 +25,7 @@ class SyntacticSuite extends scala.meta.tests.parsers.ParseSuite {
   implicit class XtensionResetOrigin[T <: Tree](tree: T) {
     // NOTE: Ensures that neither the given tree nor its subtrees have their origins set.
     // This is necessary to force prettyprinting as opposed to reusing original syntax.
-    def resetAllOrigins: T = {
-      tree.transform { case tree: Tree => tree.withOrigin(Origin.None) }.asInstanceOf[T]
-    }
+    def resetAllOrigins: T = tree.withOriginRecursive(Origin.None)
   }
 
   import scala.meta.dialects.Scala211
Repository: scalameta/scalameta
Pull request #3497 (2024-01-14 17:47:39)

InternalTrees: clean up error message in `text`


Patch:
diff --git a/scalameta/trees/shared/src/main/scala/scala/meta/internal/trees/InternalTrees.scala b/scalameta/trees/shared/src/main/scala/scala/meta/internal/trees/InternalTrees.scala
index 64b1031ce..ef5e376a3 100644
--- a/scalameta/trees/shared/src/main/scala/scala/meta/internal/trees/InternalTrees.scala
+++ b/scalameta/trees/shared/src/main/scala/scala/meta/internal/trees/InternalTrees.scala
@@ -93,7 +93,7 @@ trait InternalTree extends Product {
 
   def text: String = textOpt.getOrElse {
     throw new Error.MissingDialectException(
-      "Tree missing a dialect; update root tree `.withDialectIfRootAndNotSet` first, or call `.dialectText`."
+      "Tree missing a dialect; update root tree `.withDialectIfRootAndNotSet` first, or call `.printSyntaxFor`."
     )
   }
 


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/trees/TokensSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/trees/TokensSuite.scala
index 2f3f28a65..e6158f234 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/trees/TokensSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/trees/TokensSuite.scala
@@ -21,7 +21,7 @@ class TokensSuite extends TreeSuiteBase {
   test("Tree.tokens: manual") {
     val tree = Term.ApplyInfix(Term.Name("foo"), Term.Name("+"), Nil, List(Term.Name("bar")))
     interceptMessage[trees.Error.MissingDialectException](
-      "Tree missing a dialect; update root tree `.withDialectIfRootAndNotSet` first, or call `.dialectText`."
+      "Tree missing a dialect; update root tree `.withDialectIfRootAndNotSet` first, or call `.printSyntaxFor`."
     )(tree.text)
     assertEquals(tree.printSyntaxFor(implicitly[Dialect]), "foo + bar")
     assertEquals(tree.syntax, "foo + bar")
Repository: scalameta/scalameta
Pull request #3662 (2024-03-17 14:31:25)

Tests: fix #3655 after change in #3660


Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
index cb0597a30..fb637fbae 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
@@ -4536,7 +4536,7 @@ class ScalametaParser(input: Input)(implicit dialect: Dialect) { parser =>
     while (!StatSeqEnd(token)) {
       if (statpfAdd(token)) acceptStatSepOpt()
       else if (StatSep(token)) acceptStatSep()
-      else syntaxError(errorMsg + s" ${token.name}", at = token)
+      else syntaxError(errorMsg + s" `${token.name}`", at = token)
     }
 
     if (isIndented) accept[Indentation.Outdent]


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/LitSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/LitSuite.scala
index 783156677..263aa7a57 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/LitSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/LitSuite.scala
@@ -460,19 +460,19 @@ class LitSuite extends ParseSuite {
     ),
     (
       "0b01.2",
-      """|<input>:1: error: ; expected but double constant found
+      """|<input>:1: error: `;` expected but `double constant` found
          |0b01.2
          |    ^""".stripMargin
     ),
     (
       "1. + 2.",
-      """|<input>:1: error: ; expected but integer constant found
+      """|<input>:1: error: `;` expected but `integer constant` found
          |1. + 2.
          |     ^""".stripMargin
     ),
     (
       ".f",
-      """|<input>:1: error: illegal start of definition .
+      """|<input>:1: error: illegal start of definition `.`
          |.f
          |^""".stripMargin
     ),
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/NewFunctionsSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/NewFunctionsSuite.scala
index 8bdceace1..0145211c4 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/NewFunctionsSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/NewFunctionsSuite.scala
@@ -666,7 +666,7 @@ class NewFunctionsSuite extends BaseDottySuite {
          |  ExecutionContext
          |?=> T
          |""".stripMargin,
-      """|error: illegal start of definition ?=>
+      """|error: illegal start of definition `?=>`
          |?=> T
          |^""".stripMargin
     )
Repository: scalameta/scalameta
Pull request #3728 (2024-06-07 16:44:46)

fix: allow for type apply after splice
resolves: https://github.com/scalameta/metals/issues/6483


Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
index 7943c1925..d27d5088c 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
@@ -2130,7 +2130,7 @@ class ScalametaParser(input: Input)(implicit dialect: Dialect) {
       case _: LeftBracket => t match {
           case _: Quasi | _: Term.Name | _: Term.Select | _: Term.Apply | _: Term.ApplyInfix |
               _: Term.ApplyUnary | _: Term.New | _: Term.Placeholder | _: Term.ApplyUsing |
-              _: Term.Interpolate =>
+              _: Term.Interpolate | _: Term.SplicedMacroExpr =>
             var app: Term = t
             while (token.is[LeftBracket]) app = addPos(Term.ApplyType(app, exprTypeArgs()))
 


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/MacroSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/MacroSuite.scala
index 8e179240b..c887c093d 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/MacroSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/MacroSuite.scala
@@ -314,4 +314,13 @@ class MacroSuite extends BaseDottySuite {
     ))
     runTestAssert[Stat](code)(tree)
   }
+
+  test("#6483-metals") {
+    val code = "${ fn }[Int](0)"
+    val tree = Term.Apply(
+      Term.ApplyType(Term.SplicedMacroExpr(blk(tname("fn"))), List(Type.Name("Int"))),
+      List(lit(0))
+    )
+    runTestAssert[Stat](code)(tree)
+  }
 }
Repository: scalameta/scalameta
Pull request #2732 (2022-04-19 12:41:25)

Remove LF when soft keywords are used
Previously, we would not remove newliens between sof keyword and the next token, which would lead to issues with double newlines after transparent. Now, we properly check if an indent is a soft identifier and in that case remove the newlines in the scanner.


Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
index 5b26d29f3..efc972a6d 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
@@ -362,6 +362,7 @@ class ScannerTokens(tokens: Tokens, input: Input)(implicit dialect: Dialect) {
     @classifier
     trait CanEndStat {
       def unapply(token: Token): Boolean = token match {
+        case SoftModifier() => false
         case _: Ident | _: KwGiven | _: Literal | _: Interpolation.End | _: Xml.End | _: KwReturn |
             _: KwThis | _: KwType | _: RightParen | _: RightBracket | _: RightBrace |
             _: Underscore | _: Ellipsis | _: Unquote =>


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/InlineSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/InlineSuite.scala
index 2420f4228..9bd82a966 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/InlineSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/InlineSuite.scala
@@ -477,6 +477,23 @@ class InlineSuite extends BaseDottySuite {
     )
   }
 
+  test("transparent-trait-newlines") {
+    runTestAssert[Stat](
+      """|transparent 
+         |
+         |trait S""".stripMargin,
+      assertLayout = Some("transparent trait S")
+    )(
+      Defn.Trait(
+        List(Mod.Transparent()),
+        Type.Name("S"),
+        Nil,
+        Ctor.Primary(Nil, Name(""), Nil),
+        Template(Nil, Nil, Self(Name(""), None), Nil, Nil)
+      )
+    )
+  }
+
   test("transparent-inline-with-constant") {
     runTestAssert[Stat](
       """|transparent inline def f: String =