@@ -497,7 +497,7 @@ object Implicits {
497497 private def rootsIn (ref : TermRef )(given ctx : Context ): List [TermRef ] =
498498 if seen.contains(ref) then Nil
499499 else
500- implicitsDetailed.println(i " search in ${ref.symbol.fullName}" )
500+ implicitsDetailed.println(i " search for suggestions in ${ref.symbol.fullName}" )
501501 seen += ref
502502 val nested =
503503 if ref.symbol.is(Package ) then
@@ -538,7 +538,7 @@ object Implicits {
538538 System .currentTimeMillis < deadLine
539539 && {
540540 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}" )
542542 ctx.run.isCancelled = true
543543 }
544544 try qualifies(ref)
@@ -550,7 +550,7 @@ object Implicits {
550550 try
551551 roots
552552 .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
554554 .flatMap(_.implicitMembers.filter(test))
555555 finally scheduler.shutdown()
556556 end search
@@ -784,18 +784,14 @@ trait Implicits { self: Typer =>
784784 val suggestedRefs =
785785 try Implicits .suggestions(_ <:< pt).search(given ctx .fresh.setExploreTyperState())
786786 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 " "
795794 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
799795 val fix =
800796 if suggestions.tail.isEmpty then " The following import"
801797 else " One of the following imports"
@@ -805,6 +801,7 @@ trait Implicits { self: Typer =>
805801 |
806802 | $suggestions%\n%
807803 """
804+ end implicitSuggestionsFor
808805
809806 /** Handlers to synthesize implicits for special types */
810807 type SpecialHandler = (Type , Span ) => Context => Tree
0 commit comments