diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 460aa8d2ecc3..20274e8f087d 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1837,13 +1837,23 @@ trait Applications extends Compatibility { self: Typer with Dynamic => * () or * []() * - * where comes from `pt` if it is a PolyProto. + * where comes from `pt` if it is a (possibly ignored) PolyProto. */ def extMethodApply(methodRef: untpd.Tree, receiver: Tree, pt: Type)(implicit ctx: Context) = { - val (core, pt1) = pt.revealIgnored match { - case PolyProto(targs, restpe) => (untpd.TypeApply(methodRef, targs.map(untpd.TypedSplice(_))), restpe) - case _ => (methodRef, pt) + /** Integrate the type arguments from `currentPt` into `methodRef`, and produce + * a matching expected type. + * If `currentPt` is ignored, the new expected type will be ignored too. + */ + def integrateTypeArgs(currentPt: Type, wasIgnored: Boolean = false): (untpd.Tree, Type) = currentPt match { + case IgnoredProto(ignored) => + integrateTypeArgs(ignored, wasIgnored = true) + case PolyProto(targs, restpe) => + val core = untpd.TypeApply(methodRef, targs.map(untpd.TypedSplice(_))) + (core, if (wasIgnored) IgnoredProto(restpe) else restpe) + case _ => + (methodRef, pt) } + val (core, pt1) = integrateTypeArgs(pt) val app = typed(untpd.Apply(core, untpd.TypedSplice(receiver) :: Nil), pt1, ctx.typerState.ownedVars)( ctx.addMode(Mode.SynthesizeExtMethodReceiver)) diff --git a/tests/pos/i6900.scala b/tests/pos/i6900.scala new file mode 100644 index 000000000000..df6d308ee0e1 --- /dev/null +++ b/tests/pos/i6900.scala @@ -0,0 +1,8 @@ +object Test { + given bla[A] { def (a: A) foo[C]: C => A = _ => a } + + 1.foo.foo + 1.foo.foo[String] + 1.foo[String].foo + 1.foo[String].foo[String] +}