Skip to content

Commit 84a2f25

Browse files
committed
Add showRef utility method
1 parent bf9be6c commit 84a2f25

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
@@ -260,5 +260,9 @@ class TypeUtils:
260260

261261
self.decl(nme.CONSTRUCTOR).altsWith(isApplicable).map(_.symbol)
262262

263+
def showRef(using Context): String = self match
264+
case self: SingletonType => ctx.printer.toTextRef(self).show
265+
case _ => self.show
266+
263267
end TypeUtils
264268

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) =
@@ -1728,7 +1728,7 @@ trait Implicits:
17281728
"argument"
17291729

17301730
def showResult(r: SearchResult) = r match
1731-
case r: SearchSuccess => ctx.printer.toTextRef(r.ref).show
1731+
case r: SearchSuccess => r.ref.showRef
17321732
case r => r.show
17331733

17341734
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)