aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-16 18:33:39 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-16 18:34:24 +0100
commite1e372cc833e3e9d0d02c1ffa453667f50dbc784 (patch)
treea28dd45cf2c696204e82dddfd2a4e0ba8e06517e /src/dotty/tools/dotc/typer/Namer.scala
parent00507cf758cfafa36dc4da372a7e53028fa979a4 (diff)
downloaddotty-e1e372cc833e3e9d0d02c1ffa453667f50dbc784.tar.gz
dotty-e1e372cc833e3e9d0d02c1ffa453667f50dbc784.tar.bz2
dotty-e1e372cc833e3e9d0d02c1ffa453667f50dbc784.zip
Better handling of cyclic reference errors.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index e054aaa3a..3e39c3926 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -47,6 +47,22 @@ trait NamerContextOps { this: Context =>
def effectiveScope: Scope =
if (owner != null && owner.isClass) owner.asClass.decls
else scope
+
+ /** The symbol (stored in some typer's symTree) of an enclosing context definition */
+ def symOfContextTree(tree: untpd.Tree) = {
+ def go(ctx: Context): Symbol = {
+ val typer = ctx.typer
+ if (typer == null) NoSymbol
+ else typer.symOfTree get tree match {
+ case Some(sym) => sym
+ case None =>
+ var cx = ctx.outer
+ while (cx.typer eq typer) cx = cx.outer
+ go(cx)
+ }
+ }
+ go(this)
+ }
}
/** This class creates symbols from definitions and imports and gives them
@@ -416,7 +432,8 @@ class Namer { typer: Typer =>
}
// println(s"final inherited for $sym: ${inherited.toString}") !!!
// println(s"owner = ${sym.owner}, decls = ${sym.owner.info.decls.show}")
- def rhsType = adapt(typedAheadExpr(mdef.rhs), WildcardType).tpe.widen
+ val rhsCtx = ctx.fresh addMode Mode.InferringReturnType
+ def rhsType = adapt(typedAheadExpr(mdef.rhs)(rhsCtx), WildcardType).tpe.widen
def lhsType = fullyDefinedType(rhsType, "right-hand side", mdef.pos)
inherited orElse lhsType
}