@@ -497,7 +497,7 @@ object Implicits {
497
497
private def rootsIn (ref : TermRef )(given ctx : Context ): List [TermRef ] =
498
498
if seen.contains(ref) then Nil
499
499
else
500
- implicitsDetailed.println(i " search in ${ref.symbol.fullName}" )
500
+ implicitsDetailed.println(i " search for suggestions in ${ref.symbol.fullName}" )
501
501
seen += ref
502
502
val nested =
503
503
if ref.symbol.is(Package ) then
@@ -538,7 +538,7 @@ object Implicits {
538
538
System .currentTimeMillis < deadLine
539
539
&& {
540
540
scheduler.scheduleAfter(testOneImplicitTimeOut) {
541
- println(i " Cancelling test of $ref when making suggestions for error in ${ctx.source}" )
541
+ implicitsDetailed. println(i " Cancelling test of $ref when making suggestions for error in ${ctx.source}" )
542
542
ctx.run.isCancelled = true
543
543
}
544
544
try qualifies(ref)
@@ -550,7 +550,7 @@ object Implicits {
550
550
try
551
551
roots
552
552
.filterNot(root => defn.RootImportTypes .exists(_.symbol == root.symbol))
553
- // don't suggest things that are imported by default
553
+ // don't suggest things that are imported by default
554
554
.flatMap(_.implicitMembers.filter(test))
555
555
finally scheduler.shutdown()
556
556
end search
@@ -784,18 +784,14 @@ trait Implicits { self: Typer =>
784
784
val suggestedRefs =
785
785
try Implicits .suggestions(_ <:< pt).search(given ctx .fresh.setExploreTyperState())
786
786
catch case NonFatal (ex) => Nil
787
- def refToRawString (ref : TermRef ) = ctx.printer.toTextRef(ref).show
788
- def refToString (ref : TermRef ): String =
789
- val raw = refToRawString(ref)
790
- ref.prefix match
791
- case prefix : TermRef if ! raw.contains(" ." ) => s " ${refToRawString(prefix)}. $raw"
792
- case _ => raw
793
- def suggestStr (ref : TermRef ) = i " import ${refToString(ref)}"
794
- if suggestedRefs.isEmpty then " "
787
+ def importString (ref : TermRef ): String =
788
+ s " import ${ctx.printer.toTextRef(ref).show}"
789
+ val suggestions = suggestedRefs.map(importString)
790
+ .filter(_.contains('.' ))
791
+ .distinct // TermRefs might be different but generate the same strings
792
+ .sorted // To get test stability. TODO: Find more useful sorting criteria
793
+ if suggestions.isEmpty then " "
795
794
else
796
- val suggestions = suggestedRefs.map(suggestStr)
797
- .distinct // TermRefs might be different but generate the same strings
798
- .sorted // To get test stability. TODO: Find more useful sorting criteria
799
795
val fix =
800
796
if suggestions.tail.isEmpty then " The following import"
801
797
else " One of the following imports"
@@ -805,6 +801,7 @@ trait Implicits { self: Typer =>
805
801
|
806
802
| $suggestions%\n%
807
803
"""
804
+ end implicitSuggestionsFor
808
805
809
806
/** Handlers to synthesize implicits for special types */
810
807
type SpecialHandler = (Type , Span ) => Context => Tree
0 commit comments