@@ -2086,20 +2086,23 @@ trait Applications extends Compatibility {
2086
2086
* where <type-args> comes from `pt` if it is a (possibly ignored) PolyProto.
2087
2087
*/
2088
2088
def extMethodApply (methodRef : untpd.Tree , receiver : Tree , pt : Type )(using Context ): Tree = {
2089
- /** Integrate the type arguments from `currentPt` into `methodRef`, and produce
2090
- * a matching expected type.
2091
- * If `currentPt` is ignored, the new expected type will be ignored too.
2089
+ /** Integrate the type arguments (if any) from `currentPt` into `tree`, and produce
2090
+ * an expected type that hides the appropriate amount of information through IgnoreProto.
2092
2091
*/
2093
- def integrateTypeArgs (currentPt : Type , wasIgnored : Boolean = false ): (untpd.Tree , Type ) = currentPt match {
2094
- case IgnoredProto (ignored) =>
2095
- integrateTypeArgs(ignored, wasIgnored = true )
2092
+ def normalizePt (tree : untpd.Tree , currentPt : Type ): (untpd.Tree , Type ) = currentPt match
2093
+ // Always reveal expected arguments to guide inference (needed for i9509.scala)
2094
+ case IgnoredProto (ignored : FunOrPolyProto ) =>
2095
+ normalizePt(tree, ignored)
2096
+ // Always hide expected member to allow for chained extensions (needed for i6900.scala)
2097
+ case _ : SelectionProto =>
2098
+ (tree, IgnoredProto (currentPt))
2096
2099
case PolyProto (targs, restpe) =>
2097
- val core = untpd.TypeApply (methodRef , targs.map(untpd.TypedSplice (_)))
2098
- (core, if (wasIgnored) IgnoredProto (restpe) else restpe)
2100
+ val tree1 = untpd.TypeApply (tree , targs.map(untpd.TypedSplice (_)))
2101
+ normalizePt(tree1, restpe)
2099
2102
case _ =>
2100
- (methodRef, pt )
2101
- }
2102
- val (core, pt1) = integrateTypeArgs( pt)
2103
+ (tree, currentPt )
2104
+
2105
+ val (core, pt1) = normalizePt(methodRef, pt)
2103
2106
val app = withMode(Mode .SynthesizeExtMethodReceiver ) {
2104
2107
typed(untpd.Apply (core, untpd.TypedSplice (receiver) :: Nil ), pt1, ctx.typerState.ownedVars)
2105
2108
}
0 commit comments