diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 13 | ||||
-rw-r--r-- | tests/pos/tparam_inf.scala | 12 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 6510ba35b..47cd1cd18 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -563,7 +563,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val pos = params indexWhere (_.name == param.name) if (pos < mtpe.paramTypes.length) { val ptype = mtpe.paramTypes(pos) - if (isFullyDefined(ptype, ForceDegree.none)) return ptype + if (isFullyDefined(ptype, ForceDegree.noBottom)) return ptype } case _ => } @@ -1265,7 +1265,16 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def adapt(tree: Tree, pt: Type, original: untpd.Tree = untpd.EmptyTree)(implicit ctx: Context) = /*>|>*/ track("adapt") /*<|<*/ { /*>|>*/ ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) /*<|<*/ { - interpolateUndetVars(tree, if (tree.isDef) tree.symbol else NoSymbol) + val isMethodCall = + tree.tpe.widen match { + case (_: MethodType) | (_: PolyType) if !tree.isDef => + true + case _ => + false + } + if (!isMethodCall) // Delay tvar interpolation in method calls until they're fully applied + interpolateUndetVars(tree, if (tree.isDef) tree.symbol else NoSymbol) + tree.overwriteType(tree.tpe.simplified) adaptInterpolated(tree, pt, original) } diff --git a/tests/pos/tparam_inf.scala b/tests/pos/tparam_inf.scala new file mode 100644 index 000000000..7b0ee0b36 --- /dev/null +++ b/tests/pos/tparam_inf.scala @@ -0,0 +1,12 @@ +object Test { + def foo1[T](x: T)(implicit ev: T): Nothing = ??? + def foo2[T](x: T)(implicit ev: T): T = ??? + + def test: Unit = { + implicit val ii: Int = 42 + + foo1(10) + foo2(10) + } +} + |