@@ -3019,7 +3019,9 @@ class Typer extends Namer
3019
3019
arg.tpe match {
3020
3020
case failed : AmbiguousImplicits =>
3021
3021
val pt1 = pt.deepenProto
3022
- if ((pt1 `ne` pt) && constrainResult(tree.symbol, wtp, pt1)) implicitArgs(formals, argIndex, pt1)
3022
+ if (pt1 `ne` pt) && (pt1 ne sharpenedPt)
3023
+ && constrainResult(tree.symbol, wtp, pt1)
3024
+ then implicitArgs(formals, argIndex, pt1)
3023
3025
else arg :: implicitArgs(formals1, argIndex + 1 , pt1)
3024
3026
case failed : SearchFailureType if ! hasDefaultParams =>
3025
3027
// no need to search further, the adapt fails in any case
@@ -3264,6 +3266,16 @@ class Typer extends Namer
3264
3266
case _ => tp
3265
3267
}
3266
3268
3269
+ // If the expected type is a selection of an extension method, deepen it
3270
+ // to also propagate the argument type (which is the receiver we have
3271
+ // typechecked already). This is needed for i8311.scala. Doing so
3272
+ // for all expected types does not work since it would block the case
3273
+ // where we have an argument that must be converted with another
3274
+ // implicit conversion to the receiver type.
3275
+ def sharpenedPt = pt match
3276
+ case pt : SelectionProto if pt.name.isExtensionName => pt.deepenProto
3277
+ case _ => pt
3278
+
3267
3279
def adaptNoArgs (wtp : Type ): Tree = {
3268
3280
val ptNorm = underlyingApplied(pt)
3269
3281
def functionExpected = defn.isFunctionType(ptNorm)
@@ -3272,15 +3284,6 @@ class Typer extends Namer
3272
3284
case IgnoredProto (_ : FunOrPolyProto ) => false
3273
3285
case _ => true
3274
3286
}
3275
- // If the expected type is a selection of an extension method, deepen it
3276
- // to also propagate the argument type (which is the receiver we have
3277
- // typechecked already). This is needed for i8311.scala. Doing so
3278
- // for all expected types does not work since it would block the case
3279
- // where we have an argument that must be converted with another
3280
- // implicit conversion to the receiver type.
3281
- def sharpenedPt = pt match
3282
- case pt : SelectionProto if pt.name.isExtensionName => pt.deepenProto
3283
- case _ => pt
3284
3287
var resMatch : Boolean = false
3285
3288
wtp match {
3286
3289
case wtp : ExprType =>
0 commit comments