Skip to content

Commit

Permalink
Deprecation warnings for old syntax (xs: _* varargs)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Nov 7, 2023
1 parent f61026d commit 43714dd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Expand Up @@ -2344,11 +2344,12 @@ object Parsers {
val isVarargSplice = location.inArgs && followingIsVararg()
in.nextToken()
if isVarargSplice then
report.errorOrMigrationWarning(
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice(`future-migration`)}",
report.gradualErrorOrMigrationWarning(
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice(`3.4-migration`)}",
in.sourcePos(uscoreStart),
future)
if sourceVersion == `future-migration` then
warnFrom = `3.4`,
errorFrom = future)
if sourceVersion.isMigrating && sourceVersion.isAtLeast(`3.4-migration`) then
patch(source, Span(t.span.end, in.lastOffset), "*")
else if opStack.nonEmpty then
report.errorOrMigrationWarning(
Expand Down
5 changes: 5 additions & 0 deletions tests/neg/i18862-3.4.check
@@ -0,0 +1,5 @@
-- Error: tests/neg/i18862-3.4.scala:6:38 ------------------------------------------------------------------------------
6 |def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning
| ^
| The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
6 changes: 6 additions & 0 deletions tests/neg/i18862-3.4.scala
@@ -0,0 +1,6 @@
//> using options -Werror

import scala.language.`3.4`

def f(x: Int*): Unit = ()
def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning
6 changes: 6 additions & 0 deletions tests/neg/i18862-future-migration.scala
@@ -0,0 +1,6 @@
//> using options -Werror

import scala.language.`future-migration`

def f(x: Int*): Unit = ()
def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning
4 changes: 4 additions & 0 deletions tests/neg/i18862-future.scala
@@ -0,0 +1,4 @@
import scala.language.future

def f(x: Int*): Unit = ()
def test(xs: List[Int]): Unit = f(xs: _*) // error: migration error

0 comments on commit 43714dd

Please sign in to comment.