Skip to content

Commit f37526b

Browse files
authored
Merge pull request #5807 from dotty-staging/fix/for-2.13
A couple of fixes to compile the 2.13 standard library
2 parents 147671e + f858b84 commit f37526b

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,19 @@ class Definitions {
348348

349349
lazy val ScalaPredefModuleRef: TermRef = ctx.requiredModuleRef("scala.Predef")
350350
def ScalaPredefModule(implicit ctx: Context): Symbol = ScalaPredefModuleRef.symbol
351-
352-
lazy val Predef_ConformsR: TypeRef = ScalaPredefModule.requiredClass("<:<").typeRef
353-
def Predef_Conforms(implicit ctx: Context): Symbol = Predef_ConformsR.symbol
354351
lazy val Predef_conformsR: TermRef = ScalaPredefModule.requiredMethodRef(nme.conforms_)
355352
def Predef_conforms(implicit ctx: Context): Symbol = Predef_conformsR.symbol
356353
lazy val Predef_classOfR: TermRef = ScalaPredefModule.requiredMethodRef(nme.classOf)
357354
def Predef_classOf(implicit ctx: Context): Symbol = Predef_classOfR.symbol
358355
lazy val Predef_undefinedR: TermRef = ScalaPredefModule.requiredMethodRef(nme.???)
359356
def Predef_undefined(implicit ctx: Context): Symbol = Predef_undefinedR.symbol
360357

358+
def SubTypeClass(implicit ctx: Context): Symbol =
359+
if (isNewCollections)
360+
ctx.requiredClass("scala.<:<")
361+
else
362+
ScalaPredefModule.requiredClass("<:<")
363+
361364
lazy val ScalaRuntimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime")
362365
def ScalaRuntimeModule(implicit ctx: Context): Symbol = ScalaRuntimeModuleRef.symbol
363366
def ScalaRuntimeClass(implicit ctx: Context): ClassSymbol = ScalaRuntimeModule.moduleClass.asClass
@@ -395,8 +398,7 @@ class Definitions {
395398
def newArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newArray")
396399

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

401403
def getWrapVarargsArrayModule: Symbol = if (isNewCollections) ScalaRuntimeModule else ScalaPredefModule
402404

@@ -583,7 +585,11 @@ class Definitions {
583585

584586
lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable")
585587
def ThrowableClass(implicit ctx: Context): ClassSymbol = ThrowableType.symbol.asClass
586-
lazy val SerializableType: TypeRef = ctx.requiredClassRef("scala.Serializable")
588+
lazy val SerializableType: TypeRef =
589+
if (isNewCollections)
590+
JavaSerializableClass.typeRef
591+
else
592+
ctx.requiredClassRef("scala.Serializable")
587593
def SerializableClass(implicit ctx: Context): ClassSymbol = SerializableType.symbol.asClass
588594
lazy val StringBuilderType: TypeRef = ctx.requiredClassRef("scala.collection.mutable.StringBuilder")
589595
def StringBuilderClass(implicit ctx: Context): ClassSymbol = StringBuilderType.symbol.asClass

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,13 +844,6 @@ class TreeUnpickler(reader: TastyReader,
844844
DefDef(Nil, Nil, tpt)
845845
}
846846
}
847-
val mods =
848-
if (sym.annotations.isEmpty) untpd.EmptyModifiers
849-
else untpd.Modifiers(annotations = sym.annotations.map(_.tree))
850-
tree.withMods(mods)
851-
// record annotations in tree so that tree positions can be filled in.
852-
// Note: Once the inline PR with its changes to positions is in, this should be
853-
// no longer necessary.
854847
goto(end)
855848
setSpan(start, tree)
856849
if (!sym.isType) { // Only terms might have leaky aliases, see the documentation of `checkNoPrivateLeaks`

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ object Implicits {
140140
ctx.scala2Mode && tpw.derivesFrom(defn.FunctionClass(1)) && ref.symbol != defn.Predef_conforms
141141
val isImplicitConversion = tpw.derivesFrom(defn.ConversionClass)
142142
val isConforms = // An implementation of <:< counts as a view, except that $conforms is always omitted
143-
tpw.derivesFrom(defn.Predef_Conforms) && ref.symbol != defn.Predef_conforms
143+
tpw.derivesFrom(defn.SubTypeClass) &&
144+
(defn.isNewCollections || // In 2.13, the type of `$conforms` changed from `A <:< A` to `A => A`
145+
ref.symbol != defn.Predef_conforms)
144146
val hasExtensions = resType match {
145147
case SelectionProto(name, _, _, _) =>
146148
tpw.memberBasedOnFlags(name, required = ExtensionMethod).exists

0 commit comments

Comments
 (0)