Skip to content

Commit 1e17425

Browse files
committed
Don't cache erasedName
It does not seem to be worthwhile to spend a field in every symbol for it.
1 parent c4604fa commit 1e17425

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,6 @@ object Denotations {
734734
case _ => Signature.NotAMethod
735735
}
736736

737-
def erasedName(implicit ctx: Context): Name = symbol.erasedName
738-
739737
def derivedSingleDenotation(symbol: Symbol, info: Type)(implicit ctx: Context): SingleDenotation =
740738
if ((symbol eq this.symbol) && (info eq this.info)) this
741739
else newLikeThis(symbol, info)

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -444,23 +444,18 @@ object SymDenotations {
444444
/** `fullName` where `.' is the separator character */
445445
def fullName(implicit ctx: Context): Name = fullNameSeparated(QualifiedName)
446446

447-
private var myErasedName: Name = null
448-
449-
final override def erasedName(implicit ctx: Context): Name = {
450-
if (myErasedName == null) {
451-
myErasedName = name
452-
if (isTerm)
453-
getAnnotation(defn.AlphaAnnot) match {
454-
case Some(ann) =>
455-
ann.arguments match {
456-
case Literal(Constant(str: String)) :: Nil => myErasedName = str.toTermName
457-
case _ =>
458-
}
459-
case _ =>
460-
}
461-
}
462-
myErasedName
463-
}
447+
/** The name given in an `@alpha` annotation if one is present, `name` otherwise */
448+
final def erasedName(implicit ctx: Context): Name =
449+
if (isTerm)
450+
getAnnotation(defn.AlphaAnnot) match {
451+
case Some(ann) =>
452+
ann.arguments match {
453+
case Literal(Constant(str: String)) :: Nil => str.toTermName
454+
case _ => name
455+
}
456+
case _ => name
457+
}
458+
else name
464459

465460
// ----- Tests -------------------------------------------------
466461

0 commit comments

Comments
 (0)