Skip to content

Commit 29fe495

Browse files
committed
Simplify def mappings
1 parent 976eecb commit 29fe495

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dotty.tools.dotc.core.CheckRealizable
77
import dotty.tools.dotc.core.Decorators.StringInterpolators
88
import dotty.tools.dotc.core.Denotations.SingleDenotation
99
import dotty.tools.dotc.core.Flags._
10-
import dotty.tools.dotc.core.Names.{Name, SimpleName, TermName}
10+
import dotty.tools.dotc.core.Names.{Name, TermName}
1111
import dotty.tools.dotc.core.NameKinds.SimpleNameKind
1212
import dotty.tools.dotc.core.NameOps.NameDecorator
1313
import dotty.tools.dotc.core.Symbols.{defn, NoSymbol, Symbol}
@@ -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[TermName, 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 termName = name.stripModuleClassSuffix.toTermName
358+
nameToSymbols += termName -> (sym :: nameToSymbols.getOrElse(termName, 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[TermName, List[Symbol]] = nameToSymbols.toMap
373365
}
374366

375367
}

0 commit comments

Comments
 (0)