diff options
author | Martin Odersky <odersky@gmail.com> | 2013-08-20 17:13:22 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-08-20 17:13:22 +0200 |
commit | f19ea205446ec1d5e356097c56312829e31dfc13 (patch) | |
tree | de2bb6063ca9ff1b67ada9bdc6fb732e16a04393 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 7fb9cd47f3a5ce10e1001b9a9aa5672dc38bf16e (diff) | |
download | dotty-f19ea205446ec1d5e356097c56312829e31dfc13.tar.gz dotty-f19ea205446ec1d5e356097c56312829e31dfc13.tar.bz2 dotty-f19ea205446ec1d5e356097c56312829e31dfc13.zip |
Fixing two typer bugs
1) Context was messed up when issuing errors from findRef
2) EmptyTrees should not be adapted
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index d003b8a09..abdc041fa 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -170,6 +170,11 @@ class Typer extends Namer with Applications with Implicits { def typedIdent(tree: untpd.Ident, pt: Type)(implicit ctx: Context): Tree = { val name = tree.name + /** Method is necessary because error messages need to bind to + * to typedIdent's context which is lost in nested calls to findRef + */ + def error(msg: => String, pos: Position) = ctx.error(msg, pos) + /** Is this import a root import that has been shadowed by an explicit * import in the same program? */ @@ -229,7 +234,7 @@ class Typer extends Namer with Applications with Implicits { if (!previous.exists || (previous == found)) found else { if (!previous.isError && !found.isError) - ctx.error( + error( i"""reference to $name is ambiguous; |it is both ${bindingString(newPrec, ctx, "")} |and ${bindingString(prevPrec, prevCtx, " subsequently")}""".stripMargin, @@ -244,9 +249,9 @@ class Typer extends Namer with Applications with Implicits { def checkUnambiguous(found: Type) = { val other = namedImportRef(site, selectors.tail) if (other.exists && (found != other)) - ctx.error(i"""reference to $name is ambiguous; it is imported twice in - |${ctx.tree}""".stripMargin, - tree.pos) + error(i"""reference to $name is ambiguous; it is imported twice in + |${ctx.tree}""".stripMargin, + tree.pos) found } selectors match { @@ -336,7 +341,7 @@ class Typer extends Namer with Applications with Implicits { if (rawType.exists) checkAccessible(rawType, superAccess = false, tree.pos) else { - ctx.error(i"not found: $name", tree.pos) + error(i"not found: $name", tree.pos) ErrorType } tree.withType(ownType.underlyingIfRepeated) @@ -942,9 +947,7 @@ class Typer extends Namer with Applications with Implicits { * (14) When in mode EXPRmode, apply a view * If all this fails, error */ - def adapt(tree: Tree, pt: Type)(implicit ctx: Context): Tree = { - - println(i"adapting $tree of type ${tree.tpe} to $pt") + def adapt(tree: Tree, pt: Type)(implicit ctx: Context): Tree = ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt") { def adaptOverloaded(ref: TermRef) = { val altDenots = ref.denot.alternatives @@ -1040,6 +1043,8 @@ class Typer extends Namer with Applications with Implicits { val tvars = ctx.newTypeVars(tracked, tree.pos) adapt(tpd.TypeApply(tree, tvars map (tpd.TypeTree(_))), pt) } + case NoType if tree.isInstanceOf[WithoutType[_]] => + tree case tp => pt match { case pt: FunProtoType => adaptToArgs(tp, pt) |