Skip to content

Commit d8a0bf6

Browse files
committed
Honor @meta.getter and @meta.setter in Memoize.
1 parent d65c0d9 commit d8a0bf6

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

compiler/src/dotty/tools/dotc/transform/Memoize.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,10 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
9797
case _ => ()
9898
}
9999

100-
def removeUnwantedAnnotations(denot: SymDenotation): Unit =
100+
def removeUnwantedAnnotations(denot: SymDenotation, metaAnnotSym: ClassSymbol): Unit =
101101
if (sym.annotations.nonEmpty) {
102102
val cpy = sym.copySymDenotation()
103-
// Keep @deprecated annotation so that accessors can
104-
// be marked as deprecated in the bytecode.
105-
// TODO check the meta-annotations to know what to keep
106-
cpy.filterAnnotations(_.matches(defn.DeprecatedAnnot))
103+
cpy.filterAnnotations(_.symbol.hasAnnotation(metaAnnotSym))
107104
cpy.installAfter(thisPhase)
108105
}
109106

@@ -141,7 +138,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
141138
else transformFollowingDeep(ref(field))(using ctx.withOwner(sym))
142139
val getterDef = cpy.DefDef(tree)(rhs = getterRhs)
143140
addAnnotations(fieldDef.denot)
144-
removeUnwantedAnnotations(sym)
141+
removeUnwantedAnnotations(sym, defn.GetterMetaAnnot)
145142
Thicket(fieldDef, getterDef)
146143
else if sym.isSetter then
147144
if (!sym.is(ParamAccessor)) { val Literal(Constant(())) = tree.rhs } // This is intended as an assertion
@@ -162,7 +159,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
162159
if (isErasableBottomField(field, tree.vparamss.head.head.tpt.tpe.classSymbol)) Literal(Constant(()))
163160
else Assign(ref(field), adaptToField(field, ref(tree.vparamss.head.head.symbol)))
164161
val setterDef = cpy.DefDef(tree)(rhs = transformFollowingDeep(initializer)(using ctx.withOwner(sym)))
165-
removeUnwantedAnnotations(sym)
162+
removeUnwantedAnnotations(sym, defn.SetterMetaAnnot)
166163
setterDef
167164
else
168165
// Curiously, some accessors from Scala2 have ' ' suffixes.

0 commit comments

Comments
 (0)