From 067ef2076cfcf7864b840ddf38c514ff67f52c64 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 7 Nov 2013 21:43:59 +0100 Subject: Fixing inference problem and block scope problem 1. Typing blocks: forgot to create new scope. Now fixed. 2. The decitsion whether to interpolate a type variable was made based on the type variable's position and the current tree's position. This is too imprecise, because we might have auto-generated trees where all important parts have the same position. We now check for actual tree containment: A type variable can be interpolated for the type of a tree T if T contains the tree which introduced the type variable. --- src/dotty/tools/dotc/typer/Typer.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index e9c6b0d08..08bf6badf 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -833,7 +833,7 @@ class Typer extends Namer with Applications with Implicits { case tree: untpd.Typed => typedTyped(tree, pt) case tree: untpd.NamedArg => typedNamedArg(tree, pt) case tree: untpd.Assign => typedAssign(tree, pt) - case tree: untpd.Block => typedBlock(desugar.block(tree), pt) + case tree: untpd.Block => typedBlock(desugar.block(tree), pt)(ctx.fresh.withNewScope) case tree: untpd.If => typedIf(tree, pt) case tree: untpd.Function => typedFunction(tree, pt) case tree: untpd.Closure => typedClosure(tree, pt) @@ -933,7 +933,7 @@ class Typer extends Namer with Applications with Implicits { } def interpolateAndAdapt(tree: Tree, pt: Type)(implicit ctx: Context) = { - ctx.interpolateUndetVars(tree.tpe.widen, tree.pos) + ctx.interpolateUndetVars(tree) tree overwriteType tree.tpe.simplified adapt(tree, pt) } @@ -1107,7 +1107,7 @@ class Typer extends Namer with Applications with Implicits { else { val tvars = ctx.typerState.withCheckingDisabled { val tracked = ctx.track(poly) - ctx.newTypeVars(tracked, tree.pos) + ctx.newTypeVars(tracked, tree) } adapt(tree appliedToTypes tvars, pt) } -- cgit v1.2.3