diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/Signatures.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/Signatures.scala index eb2c1b49c5c..55aa1d8200e 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/Signatures.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/Signatures.scala @@ -119,7 +119,9 @@ trait Signatures { compiler: MetalsGlobal => } def getUsedRenames: Map[Symbol, String] = lookedUpRenames.flatMap { key => - renames.get(key).map(v => key -> v.toString()) + renames.get(key).collect { + case v if key.nameString != v.toString => key -> v.toString() + } }.toMap def this(context: Context) = diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala index d1447600960..5ea619eeb0a 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala @@ -36,7 +36,8 @@ class ShortenedNames( s"type $to = ${from.showName}" }.toList - def getUsedRenames: Map[Symbol, String] = foundRenames.toMap + def getUsedRenames(using Context): Map[Symbol, String] = + foundRenames.toMap.filter { case (k, v) => k.showName != v } /** * Returns a list of shortened names diff --git a/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala index 5aaea463977..0a2ce7f0a77 100644 --- a/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala @@ -680,4 +680,24 @@ class HoverTermSuite extends BaseHoverSuite { ) ) + check( + "import-no-rename", + """ + |import scala.collection + | + |object O { + | < 2)>> + |} + |""".stripMargin, + """|```scala + |val abc: collection.Map[Int,Int] + |``` + |""".stripMargin, + compat = Map( + "3" -> """|```scala + |val abc: scala.collection.Map[Int, Int] + |``` + |""".stripMargin + ) + ) }