Skip to content

A couple of fixes to compile the 2.13 standard library #5807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -347,16 +347,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 @@ -397,8 +400,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 @@ -585,7 +587,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 @@ -839,13 +839,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 isImplicitConverter = tpw.derivesFrom(defn.Predef_ImplicitConverter)
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