@@ -1002,11 +1002,10 @@ trait Implicits:
1002
1002
if (argument.isEmpty) i " missing implicit parameter of type $pt after typer at phase ${ctx.phase.phaseName}"
1003
1003
else i " type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}" )
1004
1004
1005
- if pt.unusableForInference
1006
- || ! argument.isEmpty && argument.tpe.unusableForInference
1007
- then return NoMatchingImplicitsFailure
1005
+ val usableForInference = ! pt.unusableForInference
1006
+ && (argument.isEmpty || ! argument.tpe.unusableForInference)
1008
1007
1009
- val result0 =
1008
+ val result0 = if usableForInference then
1010
1009
// If we are searching implicits when resolving an import symbol, start the search
1011
1010
// in the first enclosing context that does not have the same scope and owner as the current
1012
1011
// context. Without that precaution, an eligible implicit in the current scope
@@ -1023,7 +1022,7 @@ trait Implicits:
1023
1022
catch case ce : CyclicReference =>
1024
1023
ce.inImplicitSearch = true
1025
1024
throw ce
1026
- end result0
1025
+ else NoMatchingImplicitsFailure
1027
1026
1028
1027
val result =
1029
1028
result0 match {
@@ -1052,7 +1051,7 @@ trait Implicits:
1052
1051
result
1053
1052
}
1054
1053
else result
1055
- case NoMatchingImplicitsFailure =>
1054
+ case NoMatchingImplicitsFailure if usableForInference =>
1056
1055
SearchFailure (new NoMatchingImplicits (pt, argument, ctx.typerState.constraint), span)
1057
1056
case _ =>
1058
1057
result0
0 commit comments