@@ -3850,12 +3850,23 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3850
3850
implicitArgs(formals2, argIndex + 1 , pt)
3851
3851
3852
3852
val arg = inferImplicitArg(formal, tree.span.endPos)
3853
+
3854
+ def canProfitFromMoreConstraints =
3855
+ arg.tpe.isInstanceOf [AmbiguousImplicits ]
3856
+ // ambiguity could be decided by more constraints
3857
+ || ! isFullyDefined(formal, ForceDegree .none)
3858
+ // more context might constrain type variables which could make implicit scope larger
3859
+
3853
3860
arg.tpe match
3854
- case failed : AmbiguousImplicits =>
3861
+ case failed : SearchFailureType if canProfitFromMoreConstraints =>
3855
3862
val pt1 = pt.deepenProtoTrans
3856
3863
if (pt1 `ne` pt) && (pt1 ne sharpenedPt) && constrainResult(tree.symbol, wtp, pt1)
3857
- then implicitArgs(formals, argIndex, pt1)
3858
- else arg :: implicitArgs(formals1, argIndex + 1 , pt1)
3864
+ then return implicitArgs(formals, argIndex, pt1)
3865
+ case _ =>
3866
+
3867
+ arg.tpe match
3868
+ case failed : AmbiguousImplicits =>
3869
+ arg :: implicitArgs(formals1, argIndex + 1 , pt)
3859
3870
case failed : SearchFailureType =>
3860
3871
lazy val defaultArg =
3861
3872
def appPart (t : Tree ): Tree = t match
0 commit comments