diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-01 18:46:36 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-01 18:46:36 +0100 |
commit | 5491e59569b85949ffb9d6e825c9e337adccdf2d (patch) | |
tree | 53748004acc490249de0f1dfa0b093292d842d7c /compiler/src/dotty/tools/dotc/typer/Inferencing.scala | |
parent | 47d208448e614125446c7f294f8231c3fb7108d6 (diff) | |
download | dotty-5491e59569b85949ffb9d6e825c9e337adccdf2d.tar.gz dotty-5491e59569b85949ffb9d6e825c9e337adccdf2d.tar.bz2 dotty-5491e59569b85949ffb9d6e825c9e337adccdf2d.zip |
Fix #1757: Be more careful about positions of type variable binders
We interpolate a type variable if the current tree contains the type variables
binding tree. Previously, this was the application owning the variable. However,
sometimes this tree is transformed so that the containment test fails, and
type variables are instantiated too late (in the case of #1757 this was never).
We fix this by
- setting the binding tree to the type tree that first contains the type variable
- making sure that tree is never copied literally anywhere else.
It's a tricky dance, but I believe we got it right now.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Inferencing.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Inferencing.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala index aede4974a..1cb86dd72 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala @@ -216,10 +216,10 @@ object Inferencing { def interpolateUndetVars(tree: Tree, ownedBy: Symbol)(implicit ctx: Context): Unit = { val constraint = ctx.typerState.constraint val qualifies = (tvar: TypeVar) => - (tree contains tvar.owningTree) || ownedBy.exists && tvar.owner == ownedBy + (tree contains tvar.bindingTree) || ownedBy.exists && tvar.owner == ownedBy def interpolate() = Stats.track("interpolateUndetVars") { val tp = tree.tpe.widen - constr.println(s"interpolate undet vars in ${tp.show}, pos = ${tree.pos}, mode = ${ctx.mode}, undets = ${constraint.uninstVars map (tvar => s"${tvar.show}@${tvar.owningTree.pos}")}") + constr.println(s"interpolate undet vars in ${tp.show}, pos = ${tree.pos}, mode = ${ctx.mode}, undets = ${constraint.uninstVars map (tvar => s"${tvar.show}@${tvar.bindingTree.pos}")}") constr.println(s"qualifying undet vars: ${constraint.uninstVars filter qualifies map (tvar => s"$tvar / ${tvar.show}")}, constraint: ${constraint.show}") val vs = variances(tp, qualifies) |