Skip to content

Commit 53f8c61

Browse files
committed
Deprecation warnings for old syntax (xs: _* varargs)
1 parent f61026d commit 53f8c61

File tree

8 files changed

+34
-7
lines changed

8 files changed

+34
-7
lines changed

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def exec(projectDir: Path, binary: String, arguments: Seq[String], environment:
2525
import scala.jdk.CollectionConverters._
2626
val command = binary +: arguments
2727
log(command.mkString(" "))
28-
val builder = new ProcessBuilder(command: _*).directory(projectDir.toFile).inheritIO()
28+
val builder = new ProcessBuilder(command*).directory(projectDir.toFile).inheritIO()
2929
builder.environment.putAll(environment.asJava)
3030
val process = builder.start()
3131
val exitCode = process.waitFor()

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,11 +2344,12 @@ object Parsers {
23442344
val isVarargSplice = location.inArgs && followingIsVararg()
23452345
in.nextToken()
23462346
if isVarargSplice then
2347-
report.errorOrMigrationWarning(
2348-
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice(`future-migration`)}",
2347+
report.gradualErrorOrMigrationWarning(
2348+
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice(`3.4-migration`)}",
23492349
in.sourcePos(uscoreStart),
2350-
future)
2351-
if sourceVersion == `future-migration` then
2350+
warnFrom = `3.4`,
2351+
errorFrom = future)
2352+
if sourceVersion.isMigrating && sourceVersion.isAtLeast(`3.4-migration`) then
23522353
patch(source, Span(t.span.end, in.lastOffset), "*")
23532354
else if opStack.nonEmpty then
23542355
report.errorOrMigrationWarning(

tests/neg/i18862-3.4.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/neg/i18862-3.4.scala:6:38 ------------------------------------------------------------------------------
2+
6 |def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning
3+
| ^
4+
| The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead
5+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.

tests/neg/i18862-3.4.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//> using options -Werror
2+
3+
import scala.language.`3.4`
4+
5+
def f(x: Int*): Unit = ()
6+
def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//> using options -Werror
2+
3+
import scala.language.`future-migration`
4+
5+
def f(x: Int*): Unit = ()
6+
def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning

tests/neg/i18862-future.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import scala.language.future
2+
3+
def f(x: Int*): Unit = ()
4+
def test(xs: List[Int]): Unit = f(xs: _*) // error: migration error

tests/patmat/exhaustive_heuristics.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ object Test {
1818
// well, in truth, we do rewrite List() to Nil, but otherwise we do nothing
1919
// the full rewrite List(a, b) to a :: b :: Nil, for example is planned (but not sure it's a good idea)
2020
List(true, false) match {
21-
case List(_, _, _:_*) =>
22-
case List(node, _:_*) =>
21+
case List(_, _, _*) =>
22+
case List(node, _*) =>
2323
case Nil =>
2424
}
2525

tests/semanticdb/metac.expect

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,6 +3141,7 @@ Text => empty
31413141
Language => Scala
31423142
Symbols => 68 entries
31433143
Occurrences => 115 entries
3144+
Diagnostics => 1 entries
31443145
Synthetics => 3 entries
31453146

31463147
Symbols:
@@ -3330,6 +3331,10 @@ Occurrences:
33303331
[32:49..32:56): pickOne -> example/SpecialRefinement#pickOne().
33313332
[32:57..32:59): as -> example/PickOneRefinement_1#run().(as)
33323333

3334+
Diagnostics:
3335+
[32:60..32:60): [warning] The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead
3336+
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
3337+
33333338
Synthetics:
33343339
[15:23..15:34):elems.toMap => *[String, Any]
33353340
[15:23..15:34):elems.toMap => *(refl[Tuple2[String, Any]])

0 commit comments

Comments
 (0)