diff options
Diffstat (limited to 'src')
4 files changed, 39 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala index 3c6184bc24..e459494ab6 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala @@ -42,7 +42,7 @@ abstract class Changes { private def sameType(tp1: Type, tp2: Type) = { def typeOf(tp: Type): String = tp.toString + "[" + tp.getClass + "]" val res = sameType0(tp1, tp2) -// if (!res) println("\t different types: " + typeOf(tp1) + " : " + typeOf(tp2)) + //if (!res) println("\t different types: " + typeOf(tp1) + " : " + typeOf(tp2)) res } @@ -139,6 +139,8 @@ abstract class Changes { implicit val defaultReason = "types" // println("changeSet " + from + "(" + from.info + ")" // + " vs " + to + "(" + to.info + ")") + + def omitSymbols(s: Symbol): Boolean = !s.hasFlag(Flags.LOCAL | Flags.LIFTED | Flags.PRIVATE) val cs = new mutable.ListBuffer[Change] if ((from.info.parents zip to.info.parents) exists { case (t1, t2) => !sameType(t1, t2) }) @@ -148,28 +150,26 @@ abstract class Changes { // new members not yet visited val newMembers = mutable.HashSet[Symbol]() - newMembers ++= to.info.decls.iterator + newMembers ++= to.info.decls.iterator filter omitSymbols - for (o <- from.info.decls.iterator; - val n = to.info.decl(o.name)) { + for (o <- from.info.decls.iterator filter omitSymbols) { + val n = to.info.decl(o.name) newMembers -= n - if (!o.hasFlag(Flags.PRIVATE | Flags.LOCAL | Flags.LIFTED)) { - if (o.isClass) - cs ++= changeSet(o, n) - else if (n == NoSymbol) - cs += Removed(toEntity(o)) - else { - val newSym = n.suchThat(ov => sameType(ov.tpe, o.tpe)) - if (newSym == NoSymbol || moreRestrictive(o.flags, newSym.flags)) { - cs += Changed(toEntity(o))(n + " changed from " + o.tpe + " to " + n.tpe + " flags: " + Flags.flagsToString(o.flags)) - } else - newMembers -= newSym - } + if (o.isClass) + cs ++= changeSet(o, n) + else if (n == NoSymbol) + cs += Removed(toEntity(o)) + else { + val newSym = n.suchThat(ov => sameType(ov.tpe, o.tpe)) + if (newSym == NoSymbol || moreRestrictive(o.flags, newSym.flags)) + cs += Changed(toEntity(o))(n + " changed from " + o.tpe + " to " + n.tpe + " flags: " + Flags.flagsToString(o.flags)) + else + newMembers -= newSym } - } - cs ++= (newMembers map (Added compose toEntity)) + }: Unit // Give the type explicitly until #2281 is fixed + cs ++= (newMembers map (Added compose toEntity)) cs.toList } def removeChangeSet(sym: Symbol): Change = Removed(toEntity(sym)) diff --git a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala index b46a13f447..32d94d9ee9 100644 --- a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala +++ b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala @@ -116,11 +116,18 @@ trait DependencyAnalysis extends SubComponent with Files { val source: AbstractFile = unit.source.file; for (d <- unit.icode){ val name = d.toString - dependencies.emits(source, nameToFile(unit.source.file, name)) d.symbol match { - case _ : ModuleClassSymbol => + case s : ModuleClassSymbol => + val isTopLevelModule = + atPhase (currentRun.picklerPhase.next) { + !s.isImplClass && !s.isNestedClass + } + if (isTopLevelModule && (s.linkedModuleOfClass != NoSymbol)) { + dependencies.emits(source, nameToFile(unit.source.file, name)) + } dependencies.emits(source, nameToFile(unit.source.file, name + "$")) case _ => + dependencies.emits(source, nameToFile(unit.source.file, name)) } } diff --git a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala index e56bfec433..57a91bf332 100644 --- a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala @@ -63,7 +63,7 @@ object BuildManagerTest extends EvalLoop { } val result = fs.foldRight((List[AbstractFile](), List[String]()))(partition) if (!result._2.isEmpty) - println("No such file(s): " + result._2.mkString(",")) + Console.err.println("No such file(s): " + result._2.mkString(",")) Set.empty ++ result._1 } diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala index 893ed7b0e9..ef8aa1e452 100644 --- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala @@ -10,6 +10,7 @@ package interactive import scala.collection._ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} import scala.util.control.Breaks._ +import scala.tools.nsc.symtab.Flags import dependencies._ import util.FakePos @@ -90,6 +91,12 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana val coll: mutable.Map[AbstractFile, immutable.Set[AbstractFile]] = mutable.HashMap[AbstractFile, immutable.Set[AbstractFile]]() + // See if we really have coresponding symbols, not just those + // which share the name + def isCorrespondingSym(from: Symbol, to: Symbol): Boolean = + (from.hasFlag(Flags.TRAIT) == to.hasFlag(Flags.TRAIT)) && + (from.hasFlag(Flags.MODULE) == to.hasFlag(Flags.MODULE)) + def update0(files: Set[AbstractFile]): Unit = if (!files.isEmpty) { deleteClassfiles(files) val run = compiler.newRun() @@ -113,7 +120,9 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana else { val syms = defs(src) for (sym <- syms) { - definitions(src).find(_.fullNameString == sym.fullNameString) match { + definitions(src).find( + s => (s.fullNameString == sym.fullNameString) && + isCorrespondingSym(s, sym)) match { case Some(oldSym) => changesOf(oldSym) = changeSet(oldSym, sym) case _ => @@ -122,10 +131,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana } // Create a change for the top level classes that were removed val removed = definitions(src) filterNot ((s: Symbol) => - syms.find(_.fullNameString == s.fullNameString) match { - case None => false - case _ => true - }) + syms.find(_.fullNameString == s.fullNameString) != None) for (sym <- removed) { changesOf(sym) = List(removeChangeSet(sym)) } |