From 86397c940a2b4df6166a9bc9ed3e03d008f4dd57 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 8 Jan 2009 16:23:11 +0000 Subject: fixed erroneous cyclic reference error conditio... fixed erroneous cyclic reference error condition; generated new starr. --- src/compiler/scala/tools/nsc/CompilationUnits.scala | 5 ++++- .../scala/tools/nsc/typechecker/Analyzer.scala | 7 ++++++- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 18 ++++++++++-------- 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index bf02e114ab..aa7dc21909 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -8,7 +8,7 @@ package scala.tools.nsc import scala.tools.nsc.util.{FreshNameCreator,OffsetPosition,Position,SourceFile} import scala.tools.nsc.io.AbstractFile -import scala.collection.mutable.{HashSet, HashMap} +import scala.collection.mutable.{HashSet, HashMap, ListBuffer} trait CompilationUnits { self: Global => @@ -34,6 +34,9 @@ trait CompilationUnits { self: Global => */ val synthetics = new HashMap[Symbol, Tree] + /** things to check at end of compilation unit */ + val toCheck = new ListBuffer[() => Unit] + /** used to track changes in a signature */ var pickleHash : Long = 0 diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala index ca9f654b76..7315c6f2c5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala @@ -38,7 +38,12 @@ trait Analyzer extends AnyRef def newPhase(_prev: Phase): StdPhase = new StdPhase(_prev) { if (!inIDE) resetTyper() def apply(unit: CompilationUnit) { - unit.body = newTyper(rootContext(unit)).typed(unit.body) + try { + unit.body = newTyper(rootContext(unit)).typed(unit.body) + for (workItem <- unit.toCheck) workItem() + } finally { + unit.toCheck.clear() + } } } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 34a7eb5732..8cc87d2321 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1556,17 +1556,19 @@ trait Typers { self: Analyzer => } } - def typedRefinement(stats: List[Tree]): List[Tree] = { + def typedRefinement(stats: List[Tree]) { namer.enterSyms(stats) - val stats1 = typedStats(stats, NoSymbol) - for (stat <- stats1 if stat.isDef) { - val member = stat.symbol - if (!(context.owner.info.baseClasses.tail forall - (bc => member.matchingSymbol(bc, context.owner.thisType) == NoSymbol))) { - member setFlag OVERRIDE + // need to delay rest of typedRefinement to avoid cyclic reference errors + unit.toCheck += { () => + val stats1 = typedStats(stats, NoSymbol) + for (stat <- stats1 if stat.isDef) { + val member = stat.symbol + if (!(context.owner.info.baseClasses.tail forall + (bc => member.matchingSymbol(bc, context.owner.thisType) == NoSymbol))) { + member setFlag OVERRIDE + } } } - stats1 } def typedImport(imp : Import) : Import = imp -- cgit v1.2.3