@@ -1002,11 +1002,10 @@ trait Implicits:
10021002 if (argument.isEmpty) i " missing implicit parameter of type $pt after typer at phase ${ctx.phase.phaseName}"
10031003 else i " type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}" )
10041004
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)
10081007
1009- val result0 =
1008+ val result0 = if usableForInference then
10101009 // If we are searching implicits when resolving an import symbol, start the search
10111010 // in the first enclosing context that does not have the same scope and owner as the current
10121011 // context. Without that precaution, an eligible implicit in the current scope
@@ -1023,7 +1022,7 @@ trait Implicits:
10231022 catch case ce : CyclicReference =>
10241023 ce.inImplicitSearch = true
10251024 throw ce
1026- end result0
1025+ else NoMatchingImplicitsFailure
10271026
10281027 val result =
10291028 result0 match {
@@ -1052,7 +1051,7 @@ trait Implicits:
10521051 result
10531052 }
10541053 else result
1055- case NoMatchingImplicitsFailure =>
1054+ case NoMatchingImplicitsFailure if usableForInference =>
10561055 SearchFailure (new NoMatchingImplicits (pt, argument, ctx.typerState.constraint), span)
10571056 case _ =>
10581057 result0
0 commit comments