aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-05-09 18:55:10 +0200
committerSamuel Gruetter <samuel.gruetter@epfl.ch>2014-05-20 13:38:49 +0200
commit394b645dd2d44ff68597527c6c690c73653f1bcb (patch)
tree22e72a22f891c002d5fef946361d223d6f6fc1a4 /src/dotty/tools/dotc/typer/Namer.scala
parent67e5130e63b10631106490cbc1cec5adcd5273e6 (diff)
downloaddotty-394b645dd2d44ff68597527c6c690c73653f1bcb.tar.gz
dotty-394b645dd2d44ff68597527c6c690c73653f1bcb.tar.bz2
dotty-394b645dd2d44ff68597527c6c690c73653f1bcb.zip
Fix of pos/t2429
This was a hard nut to crack. The problem exemplified by t2429 is that in a situation like val x: T = foo(...) where `foo` needs implicit parameters the expected result type `T` is propagated into the typechecking of foo(...) and consequently also into the implicit parameter search. This is often necessary, for instance to instantiate type parameters. But it can lead to overconstrained searches if in fact the right expansion is val x: T = viewToT(foo(...)(implicit params)) where `viewToT` is some implicit conversion. The fix handles that case by re-hecking the application foo(...) with an empty result type, if the implicit parameter search fails. But the re-checking is very subtle as is explained in the comment to `TyperState#tryWithFallback`.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index c3f1dcc81..e9195a072 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -404,8 +404,18 @@ class Namer { typer: Typer =>
}
}
- final override def complete(denot: SymDenotation)(implicit ctx: Context) =
+ final override def complete(denot: SymDenotation)(implicit ctx: Context) = {
+ if (completions != noPrinter && ctx.typerState != this.ctx.typerState) {
+ completions.println(completions.getClass.toString)
+ def levels(c: Context): Int =
+ if (c.typerState eq this.ctx.typerState) 0
+ else if (c.typerState == null) -1
+ else if (c.outer.typerState == c.typerState) levels(c.outer)
+ else levels(c.outer) + 1
+ completions.println(s"!!!completing ${denot.symbol.showLocated} in buried typerState, gap = ${levels(ctx)}")
+ }
completeInCreationContext(denot)
+ }
def completeInCreationContext(denot: SymDenotation): Unit =
denot.info = typeSig(denot.symbol)