From 5491e59569b85949ffb9d6e825c9e337adccdf2d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 1 Dec 2016 18:46:36 +0100 Subject: 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. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/typer/Typer.scala') diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 4ec1c460f..f3417ceac 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1962,12 +1962,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit if (pt.isInstanceOf[PolyProto]) tree else { var typeArgs = tree match { - case Select(qual, nme.CONSTRUCTOR) => qual.tpe.widenDealias.argTypesLo + case Select(qual, nme.CONSTRUCTOR) => qual.tpe.widenDealias.argTypesLo.map(TypeTree) case _ => Nil } if (typeArgs.isEmpty) typeArgs = constrained(poly, tree)._2 convertNewGenericArray( - adaptInterpolated(tree.appliedToTypes(typeArgs), pt, original)) + adaptInterpolated(tree.appliedToTypeTrees(typeArgs), pt, original)) } case wtp => pt match { -- cgit v1.2.3