Skip to content

Commit f845855

Browse files
committed
Add showRef utility method
1 parent 7eae7e3 commit f845855

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeUtils.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,5 +267,9 @@ class TypeUtils:
267267

268268
self.decl(nme.CONSTRUCTOR).altsWith(isApplicable).map(_.symbol)
269269

270+
def showRef(using Context): String = self match
271+
case self: SingletonType => ctx.printer.toTextRef(self).show
272+
case _ => self.show
273+
270274
end TypeUtils
271275

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ object Implicits:
558558
var str1 = err.refStr(alt1.ref)
559559
var str2 = err.refStr(alt2.ref)
560560
if str1 == str2 then
561-
str1 = ctx.printer.toTextRef(alt1.ref).show
562-
str2 = ctx.printer.toTextRef(alt2.ref).show
561+
str1 = alt1.ref.showRef
562+
str2 = alt2.ref.showRef
563563
em"both $str1 and $str2 $qualify".withoutDisambiguation()
564564

565565
override def toAdd(using Context) =
@@ -1724,7 +1724,7 @@ trait Implicits:
17241724
"argument"
17251725

17261726
def showResult(r: SearchResult) = r match
1727-
case r: SearchSuccess => ctx.printer.toTextRef(r.ref).show
1727+
case r: SearchSuccess => r.ref.showRef
17281728
case r => r.show
17291729

17301730
result match

compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ trait ImportSuggestions:
336336
if ref.symbol.is(ExtensionMethod) then
337337
s"${ctx.printer.toTextPrefixOf(ref).show}${ref.symbol.name}"
338338
else
339-
ctx.printer.toTextRef(ref).show
339+
ref.showRef
340340
s" import $imported"
341341
val suggestions = suggestedRefs
342342
.zip(suggestedRefs.map(importString))

0 commit comments

Comments
 (0)