Skip to content

Commit

Permalink
Merge pull request #5807 from dotty-staging/fix/for-2.13
Browse files Browse the repository at this point in the history
A couple of fixes to compile the 2.13 standard library
  • Loading branch information
smarter authored Jan 29, 2019
2 parents 147671e + f858b84 commit f37526b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
18 changes: 12 additions & 6 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,19 @@ class Definitions {

lazy val ScalaPredefModuleRef: TermRef = ctx.requiredModuleRef("scala.Predef")
def ScalaPredefModule(implicit ctx: Context): Symbol = ScalaPredefModuleRef.symbol

lazy val Predef_ConformsR: TypeRef = ScalaPredefModule.requiredClass("<:<").typeRef
def Predef_Conforms(implicit ctx: Context): Symbol = Predef_ConformsR.symbol
lazy val Predef_conformsR: TermRef = ScalaPredefModule.requiredMethodRef(nme.conforms_)
def Predef_conforms(implicit ctx: Context): Symbol = Predef_conformsR.symbol
lazy val Predef_classOfR: TermRef = ScalaPredefModule.requiredMethodRef(nme.classOf)
def Predef_classOf(implicit ctx: Context): Symbol = Predef_classOfR.symbol
lazy val Predef_undefinedR: TermRef = ScalaPredefModule.requiredMethodRef(nme.???)
def Predef_undefined(implicit ctx: Context): Symbol = Predef_undefinedR.symbol

def SubTypeClass(implicit ctx: Context): Symbol =
if (isNewCollections)
ctx.requiredClass("scala.<:<")
else
ScalaPredefModule.requiredClass("<:<")

lazy val ScalaRuntimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime")
def ScalaRuntimeModule(implicit ctx: Context): Symbol = ScalaRuntimeModuleRef.symbol
def ScalaRuntimeClass(implicit ctx: Context): ClassSymbol = ScalaRuntimeModule.moduleClass.asClass
Expand Down Expand Up @@ -395,8 +398,7 @@ class Definitions {
def newArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newArray")

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

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

Expand Down Expand Up @@ -583,7 +585,11 @@ class Definitions {

lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable")
def ThrowableClass(implicit ctx: Context): ClassSymbol = ThrowableType.symbol.asClass
lazy val SerializableType: TypeRef = ctx.requiredClassRef("scala.Serializable")
lazy val SerializableType: TypeRef =
if (isNewCollections)
JavaSerializableClass.typeRef
else
ctx.requiredClassRef("scala.Serializable")
def SerializableClass(implicit ctx: Context): ClassSymbol = SerializableType.symbol.asClass
lazy val StringBuilderType: TypeRef = ctx.requiredClassRef("scala.collection.mutable.StringBuilder")
def StringBuilderClass(implicit ctx: Context): ClassSymbol = StringBuilderType.symbol.asClass
Expand Down
7 changes: 0 additions & 7 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,6 @@ class TreeUnpickler(reader: TastyReader,
DefDef(Nil, Nil, tpt)
}
}
val mods =
if (sym.annotations.isEmpty) untpd.EmptyModifiers
else untpd.Modifiers(annotations = sym.annotations.map(_.tree))
tree.withMods(mods)
// record annotations in tree so that tree positions can be filled in.
// Note: Once the inline PR with its changes to positions is in, this should be
// no longer necessary.
goto(end)
setSpan(start, tree)
if (!sym.isType) { // Only terms might have leaky aliases, see the documentation of `checkNoPrivateLeaks`
Expand Down
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ object Implicits {
ctx.scala2Mode && tpw.derivesFrom(defn.FunctionClass(1)) && ref.symbol != defn.Predef_conforms
val isImplicitConversion = tpw.derivesFrom(defn.ConversionClass)
val isConforms = // An implementation of <:< counts as a view, except that $conforms is always omitted
tpw.derivesFrom(defn.Predef_Conforms) && ref.symbol != defn.Predef_conforms
tpw.derivesFrom(defn.SubTypeClass) &&
(defn.isNewCollections || // In 2.13, the type of `$conforms` changed from `A <:< A` to `A => A`
ref.symbol != defn.Predef_conforms)
val hasExtensions = resType match {
case SelectionProto(name, _, _, _) =>
tpw.memberBasedOnFlags(name, required = ExtensionMethod).exists
Expand Down

0 comments on commit f37526b

Please sign in to comment.