Skip to content

Commit 9564161

Browse files
noti0na1WojciechMazur
authored andcommitted
Do not use the name of a symbol when not needed.
[Cherry-picked cb1d50f]
1 parent 0e4fc33 commit 9564161

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ object Scopes {
164164
*/
165165
final def filteredScope(
166166
keep: Symbol => Boolean,
167-
rename: (Symbol, Name) => Name = (_, name) => name)(using Context): Scope =
167+
rename: Symbol => Name | Null = _ => null)(using Context): Scope =
168168
var result: MutableScope | Null = null
169169
for sym <- iterator do
170170
def drop() =
171171
if result == null then result = cloneScope
172172
result.nn.unlink(sym)
173173
if keep(sym) then
174-
val newName = rename(sym, sym.name)
175-
if newName != sym.name then
174+
val newName = rename(sym)
175+
if newName != null then
176176
drop()
177177
result.nn.enter(newName, sym)
178178
else

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

+2-2
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)