From e9fa840bec1d7b67e2e24f1b5e70e679dba92147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Tue, 23 Jan 2024 11:02:38 +0100 Subject: [PATCH 1/3] Sync language.scala with main --- .../src/scala/runtime/stdLibPatches/language.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index 6018f537613b..c0dd8a74419e 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -246,6 +246,20 @@ object language: @compileTimeOnly("`3.4` can only be used at compile time in import statements") object `3.4` + /** Set source version to 3.5-migration. + * + * @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]] + */ + @compileTimeOnly("`3.5-migration` can only be used at compile time in import statements") + object `3.5-migration` + + /** Set source version to 3.5 + * + * @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]] + */ + @compileTimeOnly("`3.5` can only be used at compile time in import statements") + object `3.5` + // !!! Keep in sync with dotty.tools.dotc.config.SourceVersion !!! // Also add tests in `tests/pos/source-import-3-x.scala` and `tests/pos/source-import-3-x-migration.scala` From 40fab5146b18667941e84d4d5ad47a990b020c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Tue, 23 Jan 2024 11:03:37 +0100 Subject: [PATCH 2/3] Replace future with 3.5 This reverts commit 48e03408cce4dd351a312b2f5a5e1078d6fc59c9. --- compiler/src/dotty/tools/dotc/config/MigrationVersion.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala b/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala index 89fd9b6de715..4dd9d065395b 100644 --- a/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala @@ -33,7 +33,7 @@ object MigrationVersion: val AscriptionAfterPattern = MigrationVersion(`3.3`, future) - val ExplicitContextBoundArgument = MigrationVersion(`3.4`, future) + val ExplicitContextBoundArgument = MigrationVersion(`3.4`, `3.5`) val AlphanumericInfix = MigrationVersion(`3.4`, future) val RemoveThisQualifier = MigrationVersion(`3.4`, future) From c76806c30ca5afb419b047de0869e59d151fafa7 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 22 Jan 2024 16:58:34 +0100 Subject: [PATCH 3/3] Add tests for context bounds migration Improves tests of #19316 --- tests/neg/context-bounds-migration-3.5.check | 6 ++++++ tests/neg/context-bounds-migration-3.5.scala | 10 ++++++++++ tests/neg/context-bounds-migration-future.check | 6 ++++++ tests/neg/context-bounds-migration-future.scala | 10 ++++++++++ tests/warn/context-bounds-migration-3.4.check | 6 ++++++ ...ration.scala => context-bounds-migration-3.4.scala} | 0 6 files changed, 38 insertions(+) create mode 100644 tests/neg/context-bounds-migration-3.5.check create mode 100644 tests/neg/context-bounds-migration-3.5.scala create mode 100644 tests/neg/context-bounds-migration-future.check create mode 100644 tests/neg/context-bounds-migration-future.scala create mode 100644 tests/warn/context-bounds-migration-3.4.check rename tests/warn/{context-bounds-migration.scala => context-bounds-migration-3.4.scala} (100%) diff --git a/tests/neg/context-bounds-migration-3.5.check b/tests/neg/context-bounds-migration-3.5.check new file mode 100644 index 000000000000..dd8a2aeefbf3 --- /dev/null +++ b/tests/neg/context-bounds-migration-3.5.check @@ -0,0 +1,6 @@ +-- Error: tests/neg/context-bounds-migration-3.5.scala:9:2 ------------------------------------------------------------- +9 | foo(C[Int]()) // error + | ^^^ + | Context bounds will map to context parameters. + | A `using` clause is needed to pass explicit arguments to them. + | This code can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/neg/context-bounds-migration-3.5.scala b/tests/neg/context-bounds-migration-3.5.scala new file mode 100644 index 000000000000..e5c571d0e22e --- /dev/null +++ b/tests/neg/context-bounds-migration-3.5.scala @@ -0,0 +1,10 @@ +//> using options -source 3.5 + +class C[T] +def foo[X: C] = () + +given [T]: C[T] = C[T]() + +def Test = + foo(C[Int]()) // error + foo(using C[Int]()) // ok diff --git a/tests/neg/context-bounds-migration-future.check b/tests/neg/context-bounds-migration-future.check new file mode 100644 index 000000000000..f56da5d6b28d --- /dev/null +++ b/tests/neg/context-bounds-migration-future.check @@ -0,0 +1,6 @@ +-- [E050] Type Error: tests/neg/context-bounds-migration-future.scala:9:2 ---------------------------------------------- +9 | foo(C[Int]()) // error + | ^^^ + | method foo does not take more parameters + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/context-bounds-migration-future.scala b/tests/neg/context-bounds-migration-future.scala new file mode 100644 index 000000000000..6d0e94c0b434 --- /dev/null +++ b/tests/neg/context-bounds-migration-future.scala @@ -0,0 +1,10 @@ +//> using options -source future + +class C[T] +def foo[X: C] = () + +given [T]: C[T] = C[T]() + +def Test = + foo(C[Int]()) // error + foo(using C[Int]()) // ok diff --git a/tests/warn/context-bounds-migration-3.4.check b/tests/warn/context-bounds-migration-3.4.check new file mode 100644 index 000000000000..5341cfbe3ea5 --- /dev/null +++ b/tests/warn/context-bounds-migration-3.4.check @@ -0,0 +1,6 @@ +-- Warning: tests/warn/context-bounds-migration-3.4.scala:9:2 ---------------------------------------------------------- +9 | foo(C[Int]()) // warn + | ^^^ + | Context bounds will map to context parameters. + | A `using` clause is needed to pass explicit arguments to them. + | This code can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/warn/context-bounds-migration.scala b/tests/warn/context-bounds-migration-3.4.scala similarity index 100% rename from tests/warn/context-bounds-migration.scala rename to tests/warn/context-bounds-migration-3.4.scala