diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index a7b3c601e013..461810b5d021 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -409,9 +409,15 @@ trait Applications extends Compatibility { self: Typer with Dynamic => * @return A type transformation to apply to all arguments following this one. */ def addTyped(arg: Arg, formal: Type): Type => Type = { - addArg(typedArg(arg, formal), formal) - if (methodType.isParamDependent) - safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg)) + val targ = typedArg(arg, formal) + addArg(targ, formal) + if (methodType.isParamDependent) { + val typeOfArg = targ match { + case tp: Type => tp + case tree: tpd.Tree => tree.tpe + } + safeSubstParam(_, methodType.paramRefs(n), typeOfArg) + } else identity } diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 678e1ca99222..ce1b11ad1faf 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -202,25 +202,12 @@ object ProtoTypes { * current constraint. A test case is pos/t1756.scala. * @return True if all arguments have types (in particular, no types were forgotten). */ - def allArgTypesAreCurrent()(implicit ctx: Context): Boolean = { - evalState foreachBinding { (arg, tstate) => - if (tstate.uncommittedAncestor.constraint ne ctx.typerState.constraint) { - typr.println(i"need to invalidate $arg / ${myTypedArg(arg)}, ${tstate.constraint}, current = ${ctx.typerState.constraint}") - myTypedArg = myTypedArg.remove(arg) - evalState = evalState.remove(arg) - } - } - myTypedArg.size == args.length - } + def allArgTypesAreCurrent()(implicit ctx: Context): Boolean = false private def cacheTypedArg(arg: untpd.Tree, typerFn: untpd.Tree => Tree)(implicit ctx: Context): Tree = { var targ = myTypedArg(arg) if (targ == null) { targ = typerFn(arg) - if (!ctx.reporter.hasPending) { - myTypedArg = myTypedArg.updated(arg, targ) - evalState = evalState.updated(arg, ctx.typerState) - } } targ } @@ -229,9 +216,7 @@ object ProtoTypes { * `typedArg` into account. */ def typedArgs: List[Tree] = { - if (myTypedArgs.size != args.length) - myTypedArgs = args.mapconserve(cacheTypedArg(_, typer.typed(_))) - myTypedArgs + args.mapconserve(cacheTypedArg(_, typer.typed(_))) } /** Type single argument and remember the unadapted result in `myTypedArg`. @@ -245,8 +230,7 @@ object ProtoTypes { /** The type of the argument `arg`. * @pre `arg` has been typed before */ - def typeOfArg(arg: untpd.Tree)(implicit ctx: Context): Type = - myTypedArg(arg).tpe + def typeOfArg(arg: untpd.Tree)(implicit ctx: Context): Type = ??? private[this] var myTupled: Type = NoType diff --git a/tests/pos/i3538.scala b/tests/pos/i3538.scala new file mode 100644 index 000000000000..9f8ac49330f7 --- /dev/null +++ b/tests/pos/i3538.scala @@ -0,0 +1,14 @@ +class Inv[T] + +class Test { + implicit class Wrong(test: Test) { + def right: Any = ??? + } + implicit class Right(test: Test) { + def right(node: Any): Any = ??? + } + + def inv[T](x: T): Inv[T] = ??? + + this.right(inv(1)) +}