@@ -1837,13 +1837,23 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1837
1837
* <methodRef>(<receiver>) or
1838
1838
* <methodRef>[<type-args>](<receiver>)
1839
1839
*
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.
1841
1841
*/
1842
1842
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)
1846
1855
}
1856
+ val (core, pt1) = integrateTypeArgs(pt)
1847
1857
val app =
1848
1858
typed(untpd.Apply (core, untpd.TypedSplice (receiver) :: Nil ), pt1, ctx.typerState.ownedVars)(
1849
1859
ctx.addMode(Mode .SynthesizeExtMethodReceiver ))
0 commit comments