diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 48653ad96197..58be594445a7 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3654,11 +3654,11 @@ object Parsers { subExpr() match case rhs0 @ Ident(name) if placeholderParams.nonEmpty && name == placeholderParams.head.name && !tpt.isEmpty && mods.is(Mutable) && lhs.forall(_.isInstanceOf[Ident]) => - if sourceVersion.isAtLeast(future) then - deprecationWarning( - em"""`= _` has been deprecated; use `= uninitialized` instead. - |`uninitialized` can be imported with `scala.compiletime.uninitialized`.""", - rhsOffset) + report.errorOrMigrationWarning( + em"""`= _` has been deprecated; use `= uninitialized` instead. + |`uninitialized` can be imported with `scala.compiletime.uninitialized`.""", + in.sourcePos(rhsOffset), + from = future) placeholderParams = placeholderParams.tail atSpan(rhs0.span) { Ident(nme.WILDCARD) } case rhs0 => rhs0 diff --git a/tests/neg/uninitialized-future-migration.check b/tests/neg/uninitialized-future-migration.check new file mode 100644 index 000000000000..651ce256845c --- /dev/null +++ b/tests/neg/uninitialized-future-migration.check @@ -0,0 +1,5 @@ +-- Error: tests/neg/uninitialized-future-migration.scala:7:15 ---------------------------------------------------------- +7 | var a: Int = _ // error + | ^ + | `= _` has been deprecated; use `= uninitialized` instead. + | `uninitialized` can be imported with `scala.compiletime.uninitialized`. diff --git a/tests/neg/uninitialized-future-migration.scala b/tests/neg/uninitialized-future-migration.scala new file mode 100644 index 000000000000..d743b715bc85 --- /dev/null +++ b/tests/neg/uninitialized-future-migration.scala @@ -0,0 +1,8 @@ +//> using options -Werror + +import scala.language.`future-migration` +import scala.compiletime.uninitialized + +class Foo: + var a: Int = _ // error + var b: Int = uninitialized diff --git a/tests/neg/uninitialized-future.scala b/tests/neg/uninitialized-future.scala new file mode 100644 index 000000000000..8882b70ed48b --- /dev/null +++ b/tests/neg/uninitialized-future.scala @@ -0,0 +1,6 @@ +import scala.language.future +import scala.compiletime.uninitialized + +class Foo: + var a: Int = _ // error + var b: Int = uninitialized diff --git a/tests/pos/uninitialized-future-migration.scala b/tests/pos/uninitialized-future-migration.scala new file mode 100644 index 000000000000..a1e606dc90fb --- /dev/null +++ b/tests/pos/uninitialized-future-migration.scala @@ -0,0 +1,6 @@ +import scala.language.`future-migration` +import scala.compiletime.uninitialized + +class Foo: + var a: Int = _ // warn + var b: Int = uninitialized