@@ -44,13 +44,15 @@ object Implicits:
44
44
*/
45
45
class ImportedImplicitRef (val underlyingRef : TermRef , val importInfo : ImportInfo , val selector : Int ) extends ImplicitRef :
46
46
def implicitName (using Context ): TermName = underlyingRef.implicitName
47
+ override def toString = s " ImportedImplicitRef( $underlyingRef, $importInfo, selector= $selector) "
47
48
48
49
/** An implicit definition `ImplicitRef` that is visible under a different name, `alias`.
49
50
* Gets generated if an implicit ref is imported via a renaming import.
50
51
*/
51
52
class RenamedImplicitRef (underlyingRef : TermRef , importInfo : ImportInfo , selector : Int , val alias : TermName )
52
53
extends ImportedImplicitRef (underlyingRef, importInfo, selector):
53
54
override def implicitName (using Context ): TermName = alias
55
+ override def toString = s " ImportedImplicitRef( $underlyingRef, $importInfo, selector= $selector, alias= $alias) "
54
56
55
57
/** Both search candidates and successes are references with a specific nesting level. */
56
58
sealed trait RefAndLevel {
@@ -1157,9 +1159,6 @@ trait Implicits:
1157
1159
SearchFailure (adapted.withType(new MismatchedImplicit (ref, pt, argument)))
1158
1160
}
1159
1161
else
1160
- cand match
1161
- case Candidate (k : ImportedImplicitRef , _, _) => ctx.usages.use(k.importInfo, k.importInfo.selectors(k.selector))
1162
- case _ =>
1163
1162
SearchSuccess (adapted, ref, cand.level, cand.isExtension)(ctx.typerState, ctx.gadt)
1164
1163
}
1165
1164
end typedImplicit
@@ -1485,7 +1484,20 @@ trait Implicits:
1485
1484
validateOrdering(ord)
1486
1485
throw ex
1487
1486
1488
- rank(sort(eligible), NoMatchingImplicitsFailure , Nil )
1487
+ @ tailrec
1488
+ def markSelector (allEligible : List [Candidate ], foundRef : ImplicitRef ): Unit =
1489
+ allEligible match
1490
+ case Candidate (k : ImportedImplicitRef , _, _) :: _ if k.underlyingRef == foundRef =>
1491
+ ctx.usages.use(k.importInfo, k.importInfo.selectors(k.selector))
1492
+ case _ :: rest => markSelector(rest, foundRef)
1493
+ case nil => ()
1494
+
1495
+ rank(sort(eligible), NoMatchingImplicitsFailure , Nil ) match {
1496
+ case res : SearchSuccess if ! ctx.mode.is(Mode .ImplicitExploration ) =>
1497
+ markSelector(eligible, res.ref)
1498
+ res
1499
+ case res => res
1500
+ }
1489
1501
end searchImplicit
1490
1502
1491
1503
def isUnderSpecifiedArgument (tp : Type ): Boolean =
0 commit comments