From 131ceb123969410213dd5171e3b87f42a38191f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Thu, 28 Sep 2023 14:24:05 +0200 Subject: [PATCH] Fix #18609: Add language.`3.4` and language.`3.4-migration`. --- .../dotty/tools/dotc/config/SourceVersion.scala | 1 + .../scala/runtime/stdLibPatches/language.scala | 17 +++++++++++++++++ tests/pos/source-import-3-3-migration.scala | 1 + tests/pos/source-import-3-3.scala | 1 + tests/pos/source-import-3-4-migration.scala | 1 + tests/pos/source-import-3-4.scala | 1 + 6 files changed, 22 insertions(+) create mode 100644 tests/pos/source-import-3-3-migration.scala create mode 100644 tests/pos/source-import-3-3.scala create mode 100644 tests/pos/source-import-3-4-migration.scala create mode 100644 tests/pos/source-import-3-4.scala diff --git a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala index e9c3b0676d9f..f6db0bac0452 100644 --- a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala @@ -10,6 +10,7 @@ enum SourceVersion: case `3.2-migration`, `3.2` case `3.3-migration`, `3.3` case `3.4-migration`, `3.4` + // !!! Keep in sync with scala.runtime.stdlibPatches.language !!! case `future-migration`, `future` val isMigrating: Boolean = toString.endsWith("-migration") diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index 091e75fa06e1..f34afe682c37 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -231,4 +231,21 @@ object language: @compileTimeOnly("`3.3` can only be used at compile time in import statements") object `3.3` + /** Set source version to 3.4-migration. + * + * @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]] + */ + @compileTimeOnly("`3.4-migration` can only be used at compile time in import statements") + object `3.4-migration` + + /** Set source version to 3.4 + * + * @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]] + */ + @compileTimeOnly("`3.4` can only be used at compile time in import statements") + object `3.4` + + // !!! 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` + end language diff --git a/tests/pos/source-import-3-3-migration.scala b/tests/pos/source-import-3-3-migration.scala new file mode 100644 index 000000000000..a8d1d1683288 --- /dev/null +++ b/tests/pos/source-import-3-3-migration.scala @@ -0,0 +1 @@ +import language.`3.3-migration` diff --git a/tests/pos/source-import-3-3.scala b/tests/pos/source-import-3-3.scala new file mode 100644 index 000000000000..4d580541ebcf --- /dev/null +++ b/tests/pos/source-import-3-3.scala @@ -0,0 +1 @@ +import language.`3.3` diff --git a/tests/pos/source-import-3-4-migration.scala b/tests/pos/source-import-3-4-migration.scala new file mode 100644 index 000000000000..5270f165a30b --- /dev/null +++ b/tests/pos/source-import-3-4-migration.scala @@ -0,0 +1 @@ +import language.`3.4-migration` diff --git a/tests/pos/source-import-3-4.scala b/tests/pos/source-import-3-4.scala new file mode 100644 index 000000000000..7ae4f41ac146 --- /dev/null +++ b/tests/pos/source-import-3-4.scala @@ -0,0 +1 @@ +import language.`3.4`