Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 06565a2

Browse files
Use the flag as a way to override the compiler default value
1 parent 6f6ba8c commit 06565a2

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

‎compiler/src/dotty/tools/dotc/ast/Desugar.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ object desugar {
499499
} :+ defaultCase
500500
val body = Match(paramRef, patternMatchCases)
501501
DefDef(nme.productElementName, Nil, List(List(methodParam)), javaDotLangDot(tpnme.String), body)
502-
.withFlags(if (ctx.settings.YnewLibrary.value) Override | Synthetic else Synthetic)
502+
.withFlags(if (defn.isNewCollections) Override | Synthetic else Synthetic)
503503
}
504504

505505
if (isCaseClass)

‎compiler/src/dotty/tools/dotc/config/ScalaSettings.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ScalaSettings extends Settings.SettingGroup {
9595

9696
val Yscala2Unpickler: Setting[String] = StringSetting("-Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always")
9797
// TODO: Remove once we drop support for 2.12 standard library
98-
val YnewLibrary: Setting[Boolean] = BooleanSetting("-Ynew-library", "Inform the compiler that we are using the 2.13 standard library.")
98+
val YnewCollections: Setting[Boolean] = BooleanSetting("-Ynew-collections", "Inform the compiler that we are using the 2.13 collection library (even if the 2.12 library is on the classpath).")
9999

100100
val YnoImports: Setting[Boolean] = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
101101
val YnoInline: Setting[Boolean] = BooleanSetting("-Yno-inline", "Suppress inlining.")

‎compiler/src/dotty/tools/dotc/core/Definitions.scala‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ class Definitions {
396396
def newArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newArray")
397397

398398
// TODO: Remove once we drop support for 2.12 standard library
399-
private def isNewCollections = ctx.settings.YnewLibrary.value
399+
lazy val isNewCollections: Boolean = ctx.settings.YnewCollections.value ||
400+
ctx.base.staticRef("scala.collection.IterableOnce".toTypeName).exists
400401

401402
def getWrapVarargsArrayModule: Symbol = if (isNewCollections) ScalaRuntimeModule else ScalaPredefModule
402403

‎compiler/test/dotty/tools/dotc/CompilationTests.scala‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CompilationTests extends ParallelTesting {
4848
compileFile("tests/pos-special/completeFromSource/Test2.scala", defaultOptions.and("-sourcepath", "tests/pos-special")) +
4949
compileFile("tests/pos-special/completeFromSource/Test3.scala", defaultOptions.and("-sourcepath", "tests/pos-special", "-scansource")) +
5050
compileFile("tests/pos-special/completeFromSource/nested/Test4.scala", defaultOptions.and("-sourcepath", "tests/pos-special", "-scansource")) +
51-
compileFile("tests/pos-special/repeatedArgs213.scala", defaultOptions.and("-Ynew-library")) +
51+
compileFile("tests/pos-special/repeatedArgs213.scala", defaultOptions.and("-Ynew-collections")) +
5252
compileFilesInDir("tests/pos-special/fatal-warnings", defaultOptions.and("-Xfatal-warnings", "-feature")) +
5353
compileList(
5454
"compileMixed",
@@ -164,7 +164,7 @@ class CompilationTests extends ParallelTesting {
164164
compileFile("tests/neg-custom-args/i3627.scala", allowDeepSubtypes) +
165165
compileFile("tests/neg-custom-args/matchtype-loop.scala", allowDeepSubtypes) +
166166
compileFile("tests/neg-custom-args/completeFromSource/nested/Test1.scala", defaultOptions.and("-sourcepath", "tests/neg-custom-args", "-scansource")) +
167-
compileFile("tests/neg-custom-args/repeatedArgs213.scala", defaultOptions.and("-Ynew-library"))
167+
compileFile("tests/neg-custom-args/repeatedArgs213.scala", defaultOptions.and("-Ynew-collections"))
168168
}.checkExpectedErrors()
169169

170170
// Run tests -----------------------------------------------------------------

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /