Skip to content

Commit cb1d50f

Browse files
committed
Do not use the name of a symbol when not needed.
1 parent 7fd99b6 commit cb1d50f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ object Scopes {
165165
*/
166166
final def filteredScope(
167167
keep: Symbol => Boolean,
168-
rename: (Symbol, Name) => Name = (_, name) => name)(using Context): Scope =
168+
rename: Symbol => Name | Null = _ => null)(using Context): Scope =
169169
var result: MutableScope | Null = null
170170
for sym <- iterator do
171171
def drop() =
172172
if result == null then result = cloneScope
173173
result.nn.unlink(sym)
174174
if keep(sym) then
175-
val newName = rename(sym, sym.name)
176-
if newName != sym.name then
175+
val newName = rename(sym)
176+
if newName != null then
177177
drop()
178178
result.nn.enter(newName, sym)
179179
else

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,10 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
727727
}
728728
val erasedDecls = decls.filteredScope(
729729
keep = sym => !sym.isType || sym.isClass,
730-
rename = (sym, name) =>
730+
rename = sym =>
731731
if sym.lastKnownDenotation.unforcedAnnotation(defn.TargetNameAnnot).isDefined
732732
then sym.targetName
733-
else name
733+
else null
734734
)
735735
val selfType1 = if cls.is(Module) then cls.sourceModule.termRef else NoType
736736
tp.derivedClassInfo(NoPrefix, erasedParents, erasedDecls, selfType1)

0 commit comments

Comments
 (0)