diff options
author | odersky <odersky@gmail.com> | 2016-09-21 21:19:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 21:19:08 +0300 |
commit | a83d4369c9c7d10749e68a4b442a94544f4b837b (patch) | |
tree | a524c5367b941bdcdfa7fdda5243ad8027a6221a | |
parent | dae2d644620b150cdf83d001af54f81534f202d4 (diff) | |
parent | c9d670f4ce41662215799a728b145c6a2f6ab826 (diff) | |
download | dotty-a83d4369c9c7d10749e68a4b442a94544f4b837b.tar.gz dotty-a83d4369c9c7d10749e68a4b442a94544f4b837b.tar.bz2 dotty-a83d4369c9c7d10749e68a4b442a94544f4b837b.zip |
Merge pull request #1477 from dotty-staging/fix-bootstrap-3
Fix bootstrap, take 3
4 files changed, 41 insertions, 31 deletions
diff --git a/src/dotty/tools/backend/jvm/CollectSuperCalls.scala b/src/dotty/tools/backend/jvm/CollectSuperCalls.scala index 8f9b067ba..8285bfe4b 100644 --- a/src/dotty/tools/backend/jvm/CollectSuperCalls.scala +++ b/src/dotty/tools/backend/jvm/CollectSuperCalls.scala @@ -4,9 +4,13 @@ import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.ast.Trees._ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Symbols._ +import dotty.tools.dotc.core.Flags.Trait import dotty.tools.dotc.transform.TreeTransforms.{MiniPhaseTransform, TransformerInfo} -/** Collect all super calls except to the parent class. +/** Collect all super calls to trait members. + * + * For each super reference to trait member, register a call from the current class to the + * owner of the referenced member. * * This information is used to know if it is safe to remove a redundant mixin class. * A redundant mixin class is one that is implemented by another mixin class. As the @@ -20,9 +24,9 @@ class CollectSuperCalls extends MiniPhaseTransform { override def transformSelect(tree: Select)(implicit ctx: Context, info: TransformerInfo): Tree = { tree.qualifier match { - case Super(qual: This, mix) if mix.nonEmpty => - val classSymbol = qual.symbol.asClass.classSymbol - registerSuperCall(classSymbol, tree.symbol.owner.asClass) + case sup: Super => + if (tree.symbol.owner.is(Trait)) + registerSuperCall(ctx.owner.enclosingClass.asClass, tree.symbol.owner.asClass) case _ => } tree diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 30934605b..34bcd0757 100644 --- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -747,9 +747,13 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma */ def superInterfaces: List[Symbol] = { val directlyInheritedTraits = decorateSymbol(sym).directlyInheritedTraits + val directlyInheritedTraitsSet = directlyInheritedTraits.toSet val allBaseClasses = directlyInheritedTraits.iterator.flatMap(_.symbol.asClass.baseClasses.drop(1)).toSet val superCalls = superCallsMap.getOrElse(sym, Set.empty) - directlyInheritedTraits.filter(t => !allBaseClasses(t) || superCalls(t)) + val additional = (superCalls -- directlyInheritedTraitsSet).filter(_.is(Flags.Trait)) +// if (additional.nonEmpty) +// println(s"$fullName: adding supertraits $additional") + directlyInheritedTraits.filter(t => !allBaseClasses(t) || superCalls(t)) ++ additional } /** diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 47ec541ab..bedfb672f 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -46,7 +46,7 @@ trait SymDenotations { this: Context => val initial = denot.initial val firstPhaseId = initial.validFor.firstPhaseId.max(ctx.typerPhase.id) if ((initial ne denot) || ctx.phaseId != firstPhaseId) - ctx.withPhase(firstPhaseId).stillValidInOwner(initial.asSymDenotation) + ctx.withPhase(firstPhaseId).stillValidInOwner(initial) else stillValidInOwner(denot) } @@ -56,6 +56,7 @@ trait SymDenotations { this: Context => stillValid(owner) && ( !owner.isClass || owner.isRefinementClass + || owner.is(Scala2x) || (owner.unforcedDecls.lookupAll(denot.name) contains denot.symbol) || denot.isSelfSym) } catch { @@ -77,7 +78,7 @@ trait SymDenotations { this: Context => implicit val ctx: Context = this val initial = denot.initial if ((initial ne denot) || ctx.phaseId != initial.validFor.firstPhaseId) { - ctx.withPhase(initial.validFor.firstPhaseId).traceInvalid(initial.asSymDenotation) + ctx.withPhase(initial.validFor.firstPhaseId).traceInvalid(initial) } else try { val owner = denot.owner.denot if (!traceInvalid(owner)) explainSym("owner is invalid") @@ -346,14 +347,14 @@ object SymDenotations { else { def legalize(name: Name): Name = // JVM method names may not contain `<' or `>' characters if (is(Method)) name.replace('<', '(').replace('>', ')') else name - legalize(name.expandedName(initial.asSymDenotation.owner)) + legalize(name.expandedName(initial.owner)) } // need to use initial owner to disambiguate, as multiple private symbols with the same name // might have been moved from different origins into the same class /** The name with which the denoting symbol was created */ final def originalName(implicit ctx: Context) = { - val d = initial.asSymDenotation + val d = initial if (d is ExpandedName) d.name.unexpandedName else d.name // !!!DEBUG, was: effectiveName } @@ -435,13 +436,13 @@ object SymDenotations { /** Is this symbol an anonymous class? */ final def isAnonymousClass(implicit ctx: Context): Boolean = - isClass && (initial.asSymDenotation.name startsWith tpnme.ANON_CLASS) + isClass && (initial.name startsWith tpnme.ANON_CLASS) final def isAnonymousFunction(implicit ctx: Context) = - this.symbol.is(Method) && (initial.asSymDenotation.name startsWith nme.ANON_FUN) + this.symbol.is(Method) && (initial.name startsWith nme.ANON_FUN) final def isAnonymousModuleVal(implicit ctx: Context) = - this.symbol.is(ModuleVal) && (initial.asSymDenotation.name startsWith nme.ANON_CLASS) + this.symbol.is(ModuleVal) && (initial.name startsWith nme.ANON_CLASS) /** Is this a companion class method or companion object method? * These methods are generated by Symbols#synthesizeCompanionMethod @@ -606,7 +607,7 @@ object SymDenotations { /** Is this symbol a class that extends `AnyVal`? */ final def isValueClass(implicit ctx: Context): Boolean = { - val di = this.initial.asSymDenotation + val di = initial di.isClass && di.derivesFrom(defn.AnyValClass)(ctx.withPhase(di.validFor.firstPhaseId)) // We call derivesFrom at the initial phase both because AnyVal does not exist @@ -1164,6 +1165,8 @@ object SymDenotations { d } + override def initial: SymDenotation = super.initial.asSymDenotation + /** Install this denotation as the result of the given denotation transformer. */ override def installAfter(phase: DenotTransformer)(implicit ctx: Context): Unit = super.installAfter(phase) @@ -1226,10 +1229,13 @@ object SymDenotations { if (myTypeParams == null) myTypeParams = if (ctx.erasedTypes || is(Module)) Nil // fast return for modules to avoid scanning package decls - else if (this ne initial) initial.asSymDenotation.typeParams - else infoOrCompleter match { - case info: TypeParamsCompleter => info.completerTypeParams(symbol) - case _ => typeParamsFromDecls + else { + val di = initial + if (this ne di) di.typeParams + else infoOrCompleter match { + case info: TypeParamsCompleter => info.completerTypeParams(symbol) + case _ => typeParamsFromDecls + } } myTypeParams } diff --git a/src/dotty/tools/dotc/transform/SelectStatic.scala b/src/dotty/tools/dotc/transform/SelectStatic.scala index 504a66c2f..5d60bb984 100644 --- a/src/dotty/tools/dotc/transform/SelectStatic.scala +++ b/src/dotty/tools/dotc/transform/SelectStatic.scala @@ -19,25 +19,21 @@ class SelectStatic extends MiniPhaseTransform with IdentityDenotTransformer { th import ast.tpd._ override def phaseName: String = "selectStatic" - private val isPackage = FlagConjunction(PackageCreationFlags.bits) override def transformSelect(tree: tpd.Select)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = { val sym = tree.symbol - val r1 = - if (!sym.is(isPackage) && !sym.maybeOwner.is(isPackage) && - ( - ((sym is Flags.Module) && sym.maybeOwner.isStaticOwner) || - (sym is Flags.JavaStatic) || - (sym.maybeOwner is Flags.ImplClass) || - sym.hasAnnotation(ctx.definitions.ScalaStaticAnnot) - ) - ) - if (!tree.qualifier.symbol.is(JavaModule) && !tree.qualifier.isType) - Block(List(tree.qualifier), ref(sym)) - else tree + def isStaticMember = + (sym is Flags.Module) && sym.initial.maybeOwner.initial.isStaticOwner || + (sym is Flags.JavaStatic) || + (sym.maybeOwner is Flags.ImplClass) || + sym.hasAnnotation(ctx.definitions.ScalaStaticAnnot) + val isStaticRef = !sym.is(Package) && !sym.maybeOwner.is(Package) && isStaticMember + val tree1 = + if (isStaticRef && !tree.qualifier.symbol.is(JavaModule) && !tree.qualifier.isType) + Block(List(tree.qualifier), ref(sym)) else tree - normalize(r1) + normalize(tree1) } private def normalize(t: Tree)(implicit ctx: Context) = t match { |