From 9888e2e32bff91e072da1dfb3c6cd7d8f397a508 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 1 Nov 2023 13:51:30 +0100 Subject: [PATCH] Patch `x: _*` into `x*` (not `x *`) --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/rewrites/rewrites3x.check | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/rewrites/rewrites3x.check diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 48653ad96197..6f33376e1e48 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -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. diff --git a/tests/rewrites/rewrites3x.check b/tests/rewrites/rewrites3x.check new file mode 100644 index 000000000000..0e7e0193bdd3 --- /dev/null +++ b/tests/rewrites/rewrites3x.check @@ -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 +}