aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-14 13:07:57 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-14 13:07:57 +0100
commita0b6798f3127196114da818b18fbeda9633ca209 (patch)
treedcfed6db17fdb04a2653e44ff6644c1798de6ecf /src
parent550bf861e28a62a5057d6816e0bd336463e9b0bf (diff)
downloaddotty-a0b6798f3127196114da818b18fbeda9633ca209.tar.gz
dotty-a0b6798f3127196114da818b18fbeda9633ca209.tar.bz2
dotty-a0b6798f3127196114da818b18fbeda9633ca209.zip
Avoiding cyclic references involving module vals and imports.
Previousely, compiling all of dotc/core caused a cyclic reference. The cyclic reference was caused by evaluating a module val, which caused it to evaluate its type, which caused the evaluation of all preceding imports, which led via some hops back to the same module val. We now break the cycle by computing the signature of a module val without going through its type.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/config/Printers.scala5
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala14
3 files changed, 18 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/config/Printers.scala b/src/dotty/tools/dotc/config/Printers.scala
index 407e93714..7f9c73926 100644
--- a/src/dotty/tools/dotc/config/Printers.scala
+++ b/src/dotty/tools/dotc/config/Printers.scala
@@ -11,10 +11,11 @@ object Printers {
}
val core: Printer = noPrinter
- val typr: Printer = new Printer
- val constr: Printer = new Printer
+ val typr: Printer = noPrinter
+ val constr: Printer = noPrinter
val overload: Printer = noPrinter
val implicits: Printer = noPrinter
val unapp: Printer = noPrinter
+ val completions = noPrinter
} \ No newline at end of file
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 58f148ba5..18b5c5f8f 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -12,6 +12,7 @@ import Decorators.SymbolIteratorDecorator
import annotation.tailrec
import util.SimpleMap
import config.Config
+import config.Printers._
trait SymDenotations { this: Context =>
import SymDenotations._
@@ -127,7 +128,7 @@ object SymDenotations {
if (myFlags is Touched) throw new CyclicReference(this)
myFlags |= Touched
- Context.theBase.initialCtx.debugTraceIndented(s"completing ${this.debugString}") {
+ Context.theBase.initialCtx.traceIndented(completions, s"completing ${this.debugString}") {
// println("completing " + debugString)
completer.complete(this)
}
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 317827129..c0e39c44c 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -327,7 +327,8 @@ class Namer { typer: Typer =>
private def typeSig(sym: Symbol): Type = original match {
case original: ValDef =>
- valOrDefDefSig(original, sym, Nil, identity)(localContext(sym).withNewScope)
+ if (sym is Module) moduleValSig(sym)
+ else valOrDefDefSig(original, sym, Nil, identity)(localContext(sym).withNewScope)
case original: DefDef =>
val typer1 = new Typer
nestedTyper(sym) = typer1
@@ -420,6 +421,17 @@ class Namer { typer: Typer =>
for (param <- params) typedAheadExpr(param)
}
+ /** The signature of a module valdef.
+ * This will compute the corresponding module class TypeRef immediately
+ * without going through the defined type of the ValDef. This is necessary
+ * to avoid cyclic references involving imports and module val defs.
+ */
+ def moduleValSig(sym: Symbol)(implicit ctx: Context): Type = {
+ val clsName = sym.name.moduleClassName
+ val cls = ctx.denotNamed(clsName) suchThat (_ is ModuleClass)
+ ctx.owner.thisType select (clsName, cls)
+ }
+
/** The type signature of a ValDef or DefDef
* @param mdef The definition
* @param sym Its symbol