Skip to content

Commit

Permalink
Patch x: _* into x* (not x *) (#18814)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki authored Nov 2, 2023
2 parents afeb541 + e06022f commit bb82d4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 1 addition & 7 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ object Parsers {
in.sourcePos(uscoreStart),
future)
if sourceVersion == `future-migration` then
patch(source, Span(t.span.end, in.lastOffset), " *")
patch(source, Span(t.span.end, in.lastOffset), "*")
else if opStack.nonEmpty then
report.errorOrMigrationWarning(
em"""`_*` can be used only for last argument of method application.
Expand Down Expand Up @@ -2973,12 +2973,6 @@ object Parsers {
case p =>
p

private def warnStarMigration(p: Tree) =
report.errorOrMigrationWarning(
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead",
in.sourcePos(startOffset(p)),
from = future)

/** InfixPattern ::= SimplePattern {id [nl] SimplePattern}
*/
def infixPattern(): Tree =
Expand Down
10 changes: 10 additions & 0 deletions tests/rewrites/rewrites3x.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import scala.{collection as coll, runtime as _, *}
import coll.*

def f(xs: Int*) = xs.sum
def test =
f(List(1, 2, 3)*)

def g = { implicit (x: Int) =>
x + 1
}

0 comments on commit bb82d4c

Please sign in to comment.