From b9fb91bbc97db47b6e33f89ba152496dd41427c9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 27 Sep 2021 16:52:54 +0200 Subject: [PATCH] Allow -source 3.1 as a version It's actually equivalent to 3.0, since no new language features are supported in 3.1 relative to 3.0. --- compiler/src/dotty/tools/dotc/config/Feature.scala | 2 +- compiler/src/dotty/tools/dotc/config/ScalaSettings.scala | 2 +- compiler/src/dotty/tools/dotc/config/SourceVersion.scala | 2 +- compiler/test/dotty/tools/dotc/CompilationTests.scala | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index 024d313e069c..ed592e76ace1 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -91,7 +91,7 @@ object Feature: def warnOnMigration(msg: Message, pos: SrcPos, version: SourceVersion = defaultSourceVersion)(using Context): Boolean = if sourceVersion.isMigrating && sourceVersion.stable == version - || version == `3.0` && migrateTo3 + || (version == `3.0` || version == `3.1`) && migrateTo3 then report.migrationWarning(msg, pos) true diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index ce6bc0257f2b..a73f174ef3a2 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -52,7 +52,7 @@ trait AllScalaSettings extends CommonScalaSettings, VerboseSettings, WarningSett // it is otherwise subsumed by -explain, and should be dropped as soon as we can. val explain: Setting[Boolean] = BooleanSetting("-explain", "Explain errors in more detail.", aliases = List("--explain")) val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature")) - val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source")) + val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "3.1", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source")) val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", initialValue = true, aliases = List("--unchecked")) val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id")) val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language")) diff --git a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala index d336305bf5c4..7311beb07601 100644 --- a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala @@ -9,7 +9,7 @@ import core.Decorators.{_, given} import util.Property enum SourceVersion: - case `3.0-migration`, `3.0`, `future-migration`, `future` + case `3.0-migration`, `3.0`, `3.1`, `future-migration`, `future` val isMigrating: Boolean = toString.endsWith("-migration") diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 815748d5a3ac..0bae43e91274 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -37,7 +37,7 @@ class CompilationTests { compileFilesInDir("tests/pos-special/spec-t5545", defaultOptions), compileFilesInDir("tests/pos-special/strawman-collections", allowDeepSubtypes), compileFilesInDir("tests/pos-special/isInstanceOf", allowDeepSubtypes.and("-Xfatal-warnings")), - compileFilesInDir("tests/new", defaultOptions), + compileFilesInDir("tests/new", defaultOptions.and("-source", "3.1")), // just to see whether 3.1 works compileFilesInDir("tests/pos-scala2", scala2CompatMode), compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")), compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init")),