Skip to content

Commit 7c4b670

Browse files
committed
Handle symbols renamed multiple times better
1 parent bb6787f commit 7c4b670

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,7 @@ object Completion {
149149
val groupedSymbols = {
150150
val symbols = completions.toListWithNames
151151
val nameToSymbols = symbols.groupBy(_._2.stripModuleClassSuffix.toSimpleName)
152-
nameToSymbols.mapValues { symbols =>
153-
symbols
154-
.map(_._1)
155-
.distinct // Show symbols that have been renamed multiple times only once
156-
}.toList
152+
nameToSymbols.mapValues(_.map(_._1)).toList
157153
}
158154
groupedSymbols.map { case (name, symbols) =>
159155
val typesFirst = symbols.sortWith((s1, s2) => s1.isType && !s2.isType)
@@ -352,20 +348,20 @@ object Completion {
352348
* in the REPL and the IDE.
353349
*/
354350
private class RenameAwareScope extends Scopes.MutableScope {
355-
private[this] val renames: mutable.Map[Symbol, List[Name]] = mutable.Map.empty
351+
private[this] val nameToSymbols: mutable.Map[Name, List[Symbol]] = mutable.Map.empty
356352

357353
/** Enter the symbol `sym` in this scope, recording a potential renaming. */
358354
def enter[T <: Symbol](sym: T, name: Name)(implicit ctx: Context): T = {
359-
renames += sym -> (name :: renames.getOrElse(sym, Nil))
355+
nameToSymbols += name -> (sym :: nameToSymbols.getOrElse(name, Nil))
360356
newScopeEntry(name, sym)
361357
sym
362358
}
363359

364360
/** Lists the symbols in this scope along with the name associated with them. */
365361
def toListWithNames(implicit ctx: Context): List[(Symbol, Name)] = {
366362
for {
367-
sym <- toList
368-
name <- renames.getOrElse(sym, List(sym.name))
363+
(name, syms) <- nameToSymbols.toList
364+
sym <- syms
369365
} yield (sym, name)
370366
}
371367
}

0 commit comments

Comments
 (0)