Skip to content

Commit fa7af64

Browse files
committed
Compare unmangled name when searching for roots
Compare unmangled name when searching for roots in Scala2 and Tasty unpickling. Since we now load files with their unmangled name, we don't need to go through mangled names anymore.
1 parent c5d12d1 commit fa7af64

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,11 @@ object SymDenotations {
373373
// might have been moved from different origins into the same class
374374

375375
/** The name with which the denoting symbol was created */
376-
final def originalName(implicit ctx: Context) =
377-
initial.effectiveName
376+
final def originalName(implicit ctx: Context) = initial.effectiveName
378377

379378
/** The encoded full path name of this denotation, where outer names and inner names
380-
* are separated by `separator` strings.
381-
* Never translates expansions of operators back to operator symbol.
382-
* Drops package objects. Represents each term in the owner chain by a simple `~`.
383-
* (Note: scalac uses nothing to represent terms, which can cause name clashes
384-
* between same-named definitions in different enclosing methods. Before this commit
385-
* we used `$' but this can cause ambiguities with the class separator '$').
386-
* A separator "" means "flat name"; the real separator in this case is "$" and
387-
* enclosing packages do not form part of the name.
379+
* are separated by `separator` strings as indicated by the given name kind.
380+
* Drops package objects. Represents each term in the owner chain by a simple `_$`.
388381
*/
389382
def fullNameSeparated(kind: QualifiedNameKind)(implicit ctx: Context): Name =
390383
if (symbol == NoSymbol ||

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
417417
val end = readEnd()
418418
var name: Name = readName()
419419
if (tag == TYPEDEF || tag == TYPEPARAM) name = name.toTypeName
420-
val mname = name.mangled
421420
skipParams()
422421
val ttag = nextUnsharedTag
423422
val isAbsType = isAbstractType(ttag)
@@ -433,7 +432,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
433432
def adjustIfModule(completer: LazyType) =
434433
if (flags is Module) ctx.adjustModuleCompleter(completer, name) else completer
435434
val sym =
436-
roots.find(root => (root.owner eq ctx.owner) && root.name.mangled == mname) match {
435+
roots.find(root => (root.owner eq ctx.owner) && root.name == name) match {
437436
case Some(rootd) =>
438437
pickling.println(i"overwriting ${rootd.symbol} # ${rootd.hashCode}")
439438
rootd.info = adjustIfModule(

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
449449
}
450450
name = name.mapLast(_.decode)
451451

452-
val mname = name.mangled
453-
def nameMatches(rootName: Name) = mname == rootName.mangled
452+
def nameMatches(rootName: Name) = name == rootName
454453
def isClassRoot = nameMatches(classRoot.name) && (owner == classRoot.owner) && !(flags is ModuleClass)
455454
def isModuleClassRoot = nameMatches(moduleClassRoot.name) && (owner == moduleClassRoot.owner) && (flags is Module)
456455
def isModuleRoot = nameMatches(moduleClassRoot.name.sourceModuleName) && (owner == moduleClassRoot.owner) && (flags is Module)

0 commit comments

Comments
 (0)