From 727490ab53bdda68b36a9e38a729471094c4e6b5 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Tue, 27 Oct 2009 15:53:20 +0000 Subject: Fix for #2280 --- .../nsc/dependencies/DependencyAnalysis.scala | 3 +- .../nsc/interactive/RefinedBuildManager.scala | 120 +++++++++++---------- src/compiler/scala/tools/nsc/symtab/Symbols.scala | 1 - 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala index 4b19238b7e..cbf5d5b2dc 100644 --- a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala +++ b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala @@ -141,10 +141,9 @@ trait DependencyAnalysis extends SubComponent with Files { references += file -> (references(file) + tree.symbol.fullNameString) } tree match { - case cdef: ClassDef if !cdef.symbol.isModuleClass && !cdef.symbol.hasFlag(Flags.PACKAGE) => + case cdef: ClassDef if !cdef.symbol.hasFlag(Flags.PACKAGE) => buf += cdef.symbol super.traverse(tree) - case _ => super.traverse(tree) } diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala index 9097fc02f5..9d0f6953c4 100644 --- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala @@ -95,19 +95,28 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana } val changesOf = new mutable.HashMap[Symbol, List[Change]] - + val additionalDefs: mutable.HashSet[AbstractFile] = mutable.HashSet.empty val defs = compiler.dependencyAnalysis.definitions - for (src <- files; val syms = defs(src); sym <- syms) { - definitions(src).find(_.fullNameString == sym.fullNameString) match { - case Some(oldSym) => - changesOf(oldSym) = changeSet(oldSym, sym) - case _ => - // a new top level definition, no need to process - } + for (src <- files) { + if (definitions(src).isEmpty) + additionalDefs ++= compiler.dependencyAnalysis. + dependencies.dependentFiles(1, mutable.Set(src)) + else { + val syms = defs(src) + for (sym <- syms) { + definitions(src).find(_.fullNameString == sym.fullNameString) match { + case Some(oldSym) => + changesOf(oldSym) = changeSet(oldSym, sym) + case _ => + // a new top level definition, no need to process + } + } + } } + println("Changes: " + changesOf) updateDefinitions(files) - update(invalidated(files, changesOf)) + update(invalidated(files, changesOf) ++ additionalDefs) } /** Return the set of source files that are invalidated by the given changes. */ @@ -124,67 +133,60 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana break } - // changesOf will be empty just after initialization with a saved - // dependencies file. - if (changesOf.isEmpty) - buf ++= directDeps - else { - for ((oldSym, changes) <- changesOf; change <- changes) { + for ((oldSym, changes) <- changesOf; change <- changes) { + def checkParents(cls: Symbol, file: AbstractFile) { + val parentChange = cls.info.parents.exists(_.typeSymbol.fullNameString == oldSym.fullNameString) +// println("checkParents " + cls + " oldSym: " + oldSym + " parentChange: " + parentChange + " " + cls.info.parents) + change match { + case Changed(Class(_)) if parentChange => + invalidate(file, "parents have changed", change) - def checkParents(cls: Symbol, file: AbstractFile) { - val parentChange = cls.info.parents.exists(_.typeSymbol.fullNameString == oldSym.fullNameString) -// println("checkParents " + cls + " oldSym: " + oldSym + " parentChange: " + parentChange + " " + cls.info.parents) - change match { - case Changed(Class(_)) if parentChange => - invalidate(file, "parents have changed", change) - - case Added(Definition(_)) if parentChange => - invalidate(file, "inherited new method", change) + case Added(Definition(_)) if parentChange => + invalidate(file, "inherited new method", change) - case Removed(Definition(_)) if parentChange => - invalidate(file, "inherited method removed", change) + case Removed(Definition(_)) if parentChange => + invalidate(file, "inherited method removed", change) - case _ => () - } + case _ => () } + } - def checkInterface(cls: Symbol, file: AbstractFile) { - change match { - case Added(Definition(name)) => - if (cls.info.decls.iterator.exists(_.fullNameString == name)) - invalidate(file, "of new method with existing name", change) - case Changed(Class(name)) => - if (cls.info.typeSymbol.fullNameString == name) - invalidate(file, "self type changed", change) - case _ => - () - } + def checkInterface(cls: Symbol, file: AbstractFile) { + change match { + case Added(Definition(name)) => + if (cls.info.decls.iterator.exists(_.fullNameString == name)) + invalidate(file, "of new method with existing name", change) + case Changed(Class(name)) => + if (cls.info.typeSymbol.fullNameString == name) + invalidate(file, "self type changed", change) + case _ => + () } + } - def checkReferences(file: AbstractFile) { + def checkReferences(file: AbstractFile) { // println(file + ":" + references(file)) - val refs = references(file) - if (refs.isEmpty) - invalidate(file, "it is a direct dependency and we don't yet have finer-grained dependency information", change) - else { - change match { - case Removed(Definition(name)) if refs(name) => - invalidate(file, "it references deleted definition", change) - case Removed(Class(name)) if (refs(name)) => - invalidate(file, "it references deleted class", change) - case Changed(Definition(name)) if (refs(name)) => - invalidate(file, "it references changed definition", change) - case _ => () - } + val refs = references(file) + if (refs.isEmpty) + invalidate(file, "it is a direct dependency and we don't yet have finer-grained dependency information", change) + else { + change match { + case Removed(Definition(name)) if refs(name) => + invalidate(file, "it references deleted definition", change) + case Removed(Class(name)) if (refs(name)) => + invalidate(file, "it references deleted class", change) + case Changed(Definition(name)) if (refs(name)) => + invalidate(file, "it references changed definition", change) + case _ => () } } + } - breakable { - for (file <- directDeps) { - for (cls <- definitions(file)) checkParents(cls, file) - for (cls <- definitions(file)) checkInterface(cls, file) - checkReferences(file) - } + breakable { + for (file <- directDeps) { + for (cls <- definitions(file)) checkParents(cls, file) + for (cls <- definitions(file)) checkInterface(cls, file) + checkReferences(file) } } } diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index a94ba17d8a..ce8a2edbfa 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -1887,7 +1887,6 @@ trait Symbols { } override def cloneSymbolImpl(owner: Symbol): Symbol = { - assert(!isModuleClass) val clone = new ClassSymbol(owner, pos, name) if (thisSym != this) { clone.typeOfThis = typeOfThis -- cgit v1.2.3