Skip to content

Commit ed4004d

Browse files
committed
Simplify def mappings
1 parent 976eecb commit ed4004d

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -350,26 +350,18 @@ object Completion {
350350
* in the REPL and the IDE.
351351
*/
352352
private class RenameAwareScope extends Scopes.MutableScope {
353-
private[this] val nameToSymbols: mutable.Map[Name, List[Symbol]] = mutable.Map.empty
353+
private[this] val nameToSymbols: mutable.Map[SimpleName, List[Symbol]] = mutable.Map.empty
354354

355355
/** Enter the symbol `sym` in this scope, recording a potential renaming. */
356356
def enter[T <: Symbol](sym: T, name: Name)(implicit ctx: Context): T = {
357-
nameToSymbols += name -> (sym :: nameToSymbols.getOrElse(name, Nil))
357+
val simpleName = name.stripModuleClassSuffix.toSimpleName
358+
nameToSymbols += simpleName -> (sym :: nameToSymbols.getOrElse(simpleName, Nil))
358359
newScopeEntry(name, sym)
359360
sym
360361
}
361362

362363
/** Get the names that are known in this scope, along with the list of symbols they refer to. */
363-
def mappings(implicit ctx: Context): Map[SimpleName, List[Symbol]] = {
364-
val symbols =
365-
for {
366-
(name, syms) <- nameToSymbols.toList
367-
sym <- syms
368-
} yield (sym, name)
369-
symbols
370-
.groupBy(_._2.stripModuleClassSuffix.toSimpleName)
371-
.mapValues(_.map(_._1))
372-
}
364+
def mappings: Map[SimpleName, List[Symbol]] = nameToSymbols.toMap
373365
}
374366

375367
}

0 commit comments

Comments
 (0)