@@ -324,7 +324,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
324324
325325 case tree : Ident =>
326326 splicedName(tree.symbol) match {
327- case Some (name) => this += name
327+ case Some (name) => this += highlightTypeDef( name)
328328 case _ => printType(tree.tpe)
329329 }
330330
@@ -834,7 +834,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
834834 }
835835
836836 def printParamDef (arg : ValDef )(using elideThis : Option [Symbol ]): Unit = {
837- val name = arg.name
837+ val name = splicedName( arg.symbol).getOrElse(arg.symbol. name)
838838 val sym = arg.symbol.owner
839839 if sym.isDefDef && sym.name == " <init>" then
840840 val ClassDef (_, _, _, _, _, body) = sym.owner.tree
@@ -1409,11 +1409,26 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14091409 private def escapedString (str : String ): String = str flatMap escapedChar
14101410 }
14111411
1412+ private [this ] val names = collection.mutable.Map .empty[Symbol , String ]
1413+ private [this ] val namesIndex = collection.mutable.Map .empty[String , Int ]
1414+
14121415 private def splicedName (sym : Symbol )(using ctx : Context ): Option [String ] = {
14131416 sym.annots.find(_.symbol.owner == ctx.requiredClass(" scala.internal.quoted.showName" )).flatMap {
14141417 case Apply (_, Literal (Constant (c : String )) :: Nil ) => Some (c)
14151418 case Apply (_, Inlined (_, _, Literal (Constant (c : String ))) :: Nil ) => Some (c)
14161419 case annot => None
1420+ }.orElse {
1421+ if sym.owner.isClassDef then None
1422+ else names.get(sym).orElse {
1423+ val name0 = sym.name
1424+ val index = namesIndex.getOrElse(name0, 1 )
1425+ namesIndex(name0) = index + 1
1426+ val name =
1427+ if index == 1 then name0
1428+ else s " ` $name0${index.toString.toCharArray.map {x => (x - '0' + '₀' ).toChar}.mkString}` "
1429+ names(sym) = name
1430+ Some (name)
1431+ }
14171432 }
14181433 }
14191434
0 commit comments