Skip to content

Commit 5d45e92

Browse files
committed
Fix compiling with the 2.13 collections
- Always rely on -Ynew-collections to change our behavior, attempting to automatically detect which version we're on leads to cycles. - In the new collections, the scala.Serializable class has been replaced by a type alias of java.io.Serializable
1 parent dd1839f commit 5d45e92

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ class Definitions {
397397
def newArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newArray")
398398

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

403402
def getWrapVarargsArrayModule: Symbol = if (isNewCollections) ScalaRuntimeModule else ScalaPredefModule
404403

@@ -585,7 +584,11 @@ class Definitions {
585584

586585
lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable")
587586
def ThrowableClass(implicit ctx: Context): ClassSymbol = ThrowableType.symbol.asClass
588-
lazy val SerializableType: TypeRef = ctx.requiredClassRef("scala.Serializable")
587+
lazy val SerializableType: TypeRef =
588+
if (isNewCollections)
589+
JavaSerializableClass.typeRef
590+
else
591+
ctx.requiredClassRef("scala.Serializable")
589592
def SerializableClass(implicit ctx: Context): ClassSymbol = SerializableType.symbol.asClass
590593
lazy val StringBuilderType: TypeRef = ctx.requiredClassRef("scala.collection.mutable.StringBuilder")
591594
def StringBuilderClass(implicit ctx: Context): ClassSymbol = StringBuilderType.symbol.asClass

0 commit comments

Comments
 (0)