aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
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/dotty/tools/dotc/typer/Namer.scala
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/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala14
1 files changed, 13 insertions, 1 deletions
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