diff options
author | Martin Odersky <odersky@gmail.com> | 2006-01-19 18:19:58 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-01-19 18:19:58 +0000 |
commit | cacf5a2b6a873b60a634c78a30f6deeb283ffeec (patch) | |
tree | 1ce3c96605e60fc2f86999f8b0b8cc5db65a278a | |
parent | e885bf6a4b0110185cde628dc367091284f56c9f (diff) | |
download | scala-cacf5a2b6a873b60a634c78a30f6deeb283ffeec.tar.gz scala-cacf5a2b6a873b60a634c78a30f6deeb283ffeec.tar.bz2 scala-cacf5a2b6a873b60a634c78a30f6deeb283ffeec.zip |
8 files changed, 28 insertions, 42 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index cdf0b82e29..cafe682170 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -365,6 +365,14 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable /** A map from compiled top-level symbols to their picklers */ val symData = new HashMap[Symbol, PickleBuffer]; + /** does this run compile given class, module, or case factory? */ + def compiles(sym: Symbol): boolean = + if (sym == NoSymbol) false + else if (symSource.isDefinedAt(sym)) true + else if (!sym.owner.isPackageClass) compiles(sym.toplevelClass) + else if (sym.isModuleClass) compiles(sym.sourceModule) + else false; + def compileSources(sources: List[SourceFile]): unit = { val startTime = System.currentTimeMillis(); reporter.reset; @@ -395,27 +403,13 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable if (reporter.errors == 0) { assert(symData.isEmpty, symData.elements.toList); -/* - for (val Pair(sym, pickled) <- symData.elements.toList) { - sym setPos Position.NOPOS; -// if (symData contains sym) { -// symData -= sym; -// symData -= sym.linkedSym; -// writeSymblFile(sym, pickled) -// } -// } -*/ - for (val Pair(sym, file) <- symSource.elements) { - sym setPos Position.NOPOS; - if (sym.isTerm) sym.moduleClass setPos Position.NOPOS; - resetPackageClass(sym.owner); - } } else { for (val Pair(sym, file) <- symSource.elements) { sym.reset(new loaders.SourcefileLoader(file)); if (sym.isTerm) sym.moduleClass.reset(loaders.moduleClassLoader); } } + for (val Pair(sym, file) <- symSource.elements) resetPackageClass(sym.owner); informTime("total", startTime); } diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala index cc4d1f38f1..c1a893a351 100644 --- a/src/compiler/scala/tools/nsc/symtab/Flags.scala +++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala @@ -120,17 +120,14 @@ object Flags { .filter("" !=).mkString("", " ", ""); private def flagToString(flag: long): String = { - if (flag == LABEL) "<label>" - else if (flag == INTERFACE) "<interface>" - else if (flag == IS_ERROR) "<is-error>" + if (flag == IS_ERROR) "<is-error>" else if (flag == OVERLOADED) "<overloaded>" else if (flag == LIFTED) "<lifted>" - else if (flag == TRANS_FLAG) "<trans-flag>" else if (flag == MIXEDIN) "<mixedin>" else if (flag == EXPANDEDNAME) "<expandedname>" + else if (flag == IMPLCLASS) "<implclass>" + else if (flag == TRANS_FLAG) "<trans-flag>" else if (flag == LOCKED) "<locked>" - else if (flag == STATICMODULE) "<staticobject>" - else if (flag == STATICMEMBER) "<staticmember>" else flag.asInstanceOf[int] match { case IMPLICIT => "implicit" case FINAL => "final" @@ -144,16 +141,16 @@ object Flags { case DEFERRED => "<deferred>" case METHOD => "<method>" - case MIXIN => "mixin" case MODULE => "<module>" + case INTERFACE => "<interface>" case MUTABLE => "<mutable>" case PARAM => "<param>" case PACKAGE => "<package>" case DEPRECATED => "<deprecated>" - case COVARIANT => "<covariant>" - case CONTRAVARIANT => "<contravariant>" + case COVARIANT => "<covariant/captured/byname>" + case CONTRAVARIANT => "<contravariant/label/inconstr>" case ABSOVERRIDE => "abstract override" case LOCAL => "<local>" @@ -163,12 +160,12 @@ object Flags { case STATIC => "<static>" case CASEACCESSOR => "<caseaccessor>" + case MIXIN => "mixin" + case BRIDGE => "<bridge>" case ACCESSOR => "<accessor>" case SUPERACCESSOR => "<superaccessor>" case PARAMACCESSOR => "<paramaccessor>" - case BRIDGE => "<bridge>" - case CAPTURED => "<captured>" case _ => "" } diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index cb487da083..2965cb7f8b 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -245,9 +245,6 @@ mixin class Symbols requires SymbolTable { isClass && (isAnonymousClass || isRefinementClass || isLocal || !owner.isPackageClass && owner.isLocalClass); - /** Symbol was preloaded from package */ - final def isExternal: boolean = rawpos == Position.NOPOS; - /** A a member of class `base' is incomplete if (1) it is declared deferred or * (2) it is abstract override and its super symbol in `base' is nonexistent or inclomplete. */ @@ -430,7 +427,6 @@ mixin class Symbols requires SymbolTable { */ def reset(completer: Type): unit = { resetFlags; - rawpos = Position.NOPOS; infos = null; limit = NoPhase.id; setInfo(completer) diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 67b6708f19..b5df4faec9 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1340,7 +1340,7 @@ mixin class Types requires SymbolTable { val pre1 = this(pre); val args1 = List.mapConserve(args)(this); val sym1 = adaptToNewRun(pre1, sym); - if ((pre1 eq pre) && (sym1 eq sym) && (args1 eq args) && sym.isExternal) tp + if ((pre1 eq pre) && (sym1 eq sym) && (args1 eq args)/* && sym.isExternal*/) tp else typeRef(pre1, sym1, args1) } case PolyType(tparams, restp) => diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index e8441dde87..4bb09c2271 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -29,7 +29,7 @@ abstract class Pickler extends SubComponent { def pickle(tree: Tree): unit = { def add(sym: Symbol, pickle: Pickle) = { - if (!sym.isExternal && !currentRun.symData.contains(sym)) { + if (currentRun.compiles(sym) && !currentRun.symData.contains(sym)) { if (settings.debug.value) log("pickling " + sym); pickle.putSymbol(sym); currentRun.symData(sym) = pickle; diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 3f1f3a0a13..e6110d3976 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -52,6 +52,7 @@ abstract class AddInterfaces extends InfoTransform { impl.name = implName; if (iface.owner.isClass) iface.owner.info.decls enter impl } + if (currentRun.compiles(iface)) currentRun.symSource(impl) = iface.sourceFile; impl setPos iface.pos; impl.flags = iface.flags & ~(INTERFACE | lateINTERFACE) | IMPLCLASS; impl setInfo new LazyImplClassType(iface); @@ -69,7 +70,7 @@ abstract class AddInterfaces extends InfoTransform { if (isInterfaceMember(sym)) { if (needsImplMethod(sym)) { val impl = sym.cloneSymbol(implClass).setInfo(sym.info).resetFlag(lateDEFERRED); - if (!impl.isExternal) implMethodMap(sym) = impl; + if (currentRun.compiles(implClass)) implMethodMap(sym) = impl; decls enter impl; sym setFlag lateDEFERRED } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index ec9677f7be..cfea971284 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -120,7 +120,7 @@ trait Namers requires Analyzer { private def enterClassSymbol(pos: int, flags: int, name: Name): Symbol = { var c: Symbol = context.scope.lookup(name); - if (c.isType && c.isExternal && context.scope == c.owner.info.decls) { + if (c.isType && !currentRun.compiles(c) && context.scope == c.owner.info.decls) { updatePosFlags(c, pos, flags); } else { c = enterInScope(context.owner.newClass(pos, name)).setFlag(flags | inConstructorFlag); @@ -135,10 +135,8 @@ trait Namers requires Analyzer { } if (clazz.sourceFile != null) { - if (currentRun.symSource.isDefinedAt(c) && currentRun.symSource(c) != null && - !currentRun.symSource(c).equals(clazz.sourceFile)) - throw new Error(""+currentRun.symSource(c) + " vs. " + clazz.sourceFile + " SYM=" + currentRun + " " + c); - else currentRun.symSource(c) = clazz.sourceFile; + assert(!currentRun.compiles(clazz) || clazz.sourceFile == currentRun.symSource(c)); + currentRun.symSource(c) = clazz.sourceFile } } c @@ -146,10 +144,10 @@ trait Namers requires Analyzer { private def enterModuleSymbol(pos: int, flags: int, name: Name): Symbol = { var m: Symbol = context.scope.lookup(name); - if (m.isModule && !m.isPackage && m.isExternal && (context.scope == m.owner.info.decls)) { + if (m.isModule && !m.isPackage && !currentRun.compiles(m) && (context.scope == m.owner.info.decls)) { updatePosFlags(m, pos, flags) } else { - if (m.isTerm && !m.isPackage && m.isExternal && (context.scope == m.owner.info.decls)) + if (m.isTerm && !m.isPackage && !currentRun.compiles(m) && (context.scope == m.owner.info.decls)) context.scope.unlink(m); m = context.owner.newModule(pos, name); m.setFlag(flags); @@ -163,7 +161,7 @@ trait Namers requires Analyzer { private def enterCaseFactorySymbol(pos: int, flags: int, name: Name): Symbol = { var m: Symbol = context.scope.lookup(name); - if (m.isTerm && !m.isPackage && m.isExternal && context.scope == m.owner.info.decls) { + if (m.isTerm && !m.isPackage && !currentRun.compiles(m) && context.scope == m.owner.info.decls) { updatePosFlags(m, pos, flags) } else { m = enterInScope(context.owner.newMethod(pos, name)).setFlag(flags); diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9e796585f0..7aa79333d9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1071,7 +1071,7 @@ mixin class Typers requires Analyzer { // compilation units if (defSym.tpe != NoType && impSym.tpe != NoType && defSym.owner.isPackageClass && - (defSym.isExternal || + (!currentRun.compiles(defSym) || context.unit != null && defSym.sourceFile != context.unit.source.file)) defSym = NoSymbol |