From 59f410c00c45502be955e68fedafc9e706646002 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 22 Oct 2021 17:20:48 +0200 Subject: [PATCH] Add `scala.language.{3.1, 3.1-migration}` Fixes #13773 --- .../scala/runtime/stdLibPatches/language.scala | 18 +++++++++++++++++- project/MiMaFilters.scala | 8 ++++++++ tests/pos/source-import-3-0-migration.scala | 1 + tests/pos/source-import-3-0.scala | 1 + tests/pos/source-import-3-1-migration.scala | 1 + tests/pos/source-import-3-1.scala | 1 + 6 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/pos/source-import-3-0-migration.scala create mode 100644 tests/pos/source-import-3-0.scala create mode 100644 tests/pos/source-import-3-1-migration.scala create mode 100644 tests/pos/source-import-3-1.scala diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index d7084e8850d8..98351bedc677 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -148,17 +148,33 @@ object language: @compileTimeOnly("`3.0` can only be used at compile time in import statements") object `3.0` -/* This can be added when we go to 3.1 /** Set source version to 3.1-migration. * * @see [[https://scalacenter.github.io/scala-3-migration-guide/docs/scala-3-migration-mode]] */ + @compileTimeOnly("`3.1-migration` can only be used at compile time in import statements") object `3.1-migration` /** Set source version to 3.1 * * @see [[https://scalacenter.github.io/scala-3-migration-guide/docs/scala-3-migration-mode]] */ + @compileTimeOnly("`3.1` can only be used at compile time in import statements") object `3.1` + +/* This can be added when we go to 3.2 + /** Set source version to 3.2-migration. + * + * @see [[https://scalacenter.github.io/scala-3-migration-guide/docs/scala-3-migration-mode]] + */ + @compileTimeOnly("`3.2-migration` can only be used at compile time in import statements") + object `3.2-migration` + + /** Set source version to 3.2 + * + * @see [[https://scalacenter.github.io/scala-3-migration-guide/docs/scala-3-migration-mode]] + */ + @compileTimeOnly("`3.2` can only be used at compile time in import statements") + object `3.2` */ end language diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index 4ef5e4d69c57..ae3673016db1 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -9,5 +9,13 @@ object MiMaFilters { ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.Tuples.append"), ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TypeReprMethods.substituteTypes"), ProblemFilters.exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TypeReprMethods.substituteTypes"), + + // Should have been added in 3.1.0 + // These are only allowed on imports and therefore should not be present in binaries emitted before + // this addition of these members and therefore should not cause any conflicts. + ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language.3.1-migration"), + ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language.3.1"), + ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$3$u002E1$"), + ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$3$u002E1$minusmigration$"), ) } diff --git a/tests/pos/source-import-3-0-migration.scala b/tests/pos/source-import-3-0-migration.scala new file mode 100644 index 000000000000..b0f220fd4e40 --- /dev/null +++ b/tests/pos/source-import-3-0-migration.scala @@ -0,0 +1 @@ +import language.`3.0-migration` diff --git a/tests/pos/source-import-3-0.scala b/tests/pos/source-import-3-0.scala new file mode 100644 index 000000000000..d6d7f9201b08 --- /dev/null +++ b/tests/pos/source-import-3-0.scala @@ -0,0 +1 @@ +import language.`3.0` diff --git a/tests/pos/source-import-3-1-migration.scala b/tests/pos/source-import-3-1-migration.scala new file mode 100644 index 000000000000..6e6f9f905b99 --- /dev/null +++ b/tests/pos/source-import-3-1-migration.scala @@ -0,0 +1 @@ +import language.`3.1-migration` diff --git a/tests/pos/source-import-3-1.scala b/tests/pos/source-import-3-1.scala new file mode 100644 index 000000000000..38216d612864 --- /dev/null +++ b/tests/pos/source-import-3-1.scala @@ -0,0 +1 @@ +import language.`3.1`