@@ -1837,13 +1837,23 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
18371837 * <methodRef>(<receiver>) or
18381838 * <methodRef>[<type-args>](<receiver>)
18391839 *
1840- * where <type-args> comes from `pt` if it is a PolyProto.
1840+ * where <type-args> comes from `pt` if it is a (possibly ignored) PolyProto.
18411841 */
18421842 def extMethodApply (methodRef : untpd.Tree , receiver : Tree , pt : Type )(implicit ctx : Context ) = {
1843- val (core, pt1) = pt.revealIgnored match {
1844- case PolyProto (targs, restpe) => (untpd.TypeApply (methodRef, targs.map(untpd.TypedSplice (_))), restpe)
1845- case _ => (methodRef, pt)
1843+ /** Integrate the type arguments from `currentPt` into `methodRef`, and produce
1844+ * a matching expected type.
1845+ * If `currentPt` is ignored, the new expected type will be ignored too.
1846+ */
1847+ def integrateTypeArgs (currentPt : Type , wasIgnored : Boolean = false ): (untpd.Tree , Type ) = currentPt match {
1848+ case IgnoredProto (ignored) =>
1849+ integrateTypeArgs(ignored, wasIgnored = true )
1850+ case PolyProto (targs, restpe) =>
1851+ val core = untpd.TypeApply (methodRef, targs.map(untpd.TypedSplice (_)))
1852+ (core, if (wasIgnored) IgnoredProto (restpe) else restpe)
1853+ case _ =>
1854+ (methodRef, pt)
18461855 }
1856+ val (core, pt1) = integrateTypeArgs(pt)
18471857 val app =
18481858 typed(untpd.Apply (core, untpd.TypedSplice (receiver) :: Nil ), pt1, ctx.typerState.ownedVars)(
18491859 ctx.addMode(Mode .SynthesizeExtMethodReceiver ))
0 commit comments