@@ -2998,7 +2998,9 @@ class Typer extends Namer
2998
2998
arg.tpe match {
2999
2999
case failed : AmbiguousImplicits =>
3000
3000
val pt1 = pt.deepenProto
3001
- if ((pt1 `ne` pt) && constrainResult(tree.symbol, wtp, pt1)) implicitArgs(formals, argIndex, pt1)
3001
+ if (pt1 `ne` pt) && (pt1 ne sharpenedPt)
3002
+ && constrainResult(tree.symbol, wtp, pt1)
3003
+ then implicitArgs(formals, argIndex, pt1)
3002
3004
else arg :: implicitArgs(formals1, argIndex + 1 , pt1)
3003
3005
case failed : SearchFailureType if ! hasDefaultParams =>
3004
3006
// no need to search further, the adapt fails in any case
@@ -3243,6 +3245,16 @@ class Typer extends Namer
3243
3245
case _ => tp
3244
3246
}
3245
3247
3248
+ // If the expected type is a selection of an extension method, deepen it
3249
+ // to also propagate the argument type (which is the receiver we have
3250
+ // typechecked already). This is needed for i8311.scala. Doing so
3251
+ // for all expected types does not work since it would block the case
3252
+ // where we have an argument that must be converted with another
3253
+ // implicit conversion to the receiver type.
3254
+ def sharpenedPt = pt match
3255
+ case pt : SelectionProto if pt.name.isExtensionName => pt.deepenProto
3256
+ case _ => pt
3257
+
3246
3258
def adaptNoArgs (wtp : Type ): Tree = {
3247
3259
val ptNorm = underlyingApplied(pt)
3248
3260
def functionExpected = defn.isFunctionType(ptNorm)
@@ -3251,15 +3263,6 @@ class Typer extends Namer
3251
3263
case IgnoredProto (_ : FunOrPolyProto ) => false
3252
3264
case _ => true
3253
3265
}
3254
- // If the expected type is a selection of an extension method, deepen it
3255
- // to also propagate the argument type (which is the receiver we have
3256
- // typechecked already). This is needed for i8311.scala. Doing so
3257
- // for all expected types does not work since it would block the case
3258
- // where we have an argument that must be converted with another
3259
- // implicit conversion to the receiver type.
3260
- def sharpenedPt = pt match
3261
- case pt : SelectionProto if pt.name.isExtensionName => pt.deepenProto
3262
- case _ => pt
3263
3266
var resMatch : Boolean = false
3264
3267
wtp match {
3265
3268
case wtp : ExprType =>
0 commit comments