@@ -4,7 +4,7 @@ package transform
4
4
import core ._
5
5
import DenotTransformers ._
6
6
import Contexts ._
7
- import Phases .phaseOf
7
+ import Phases .*
8
8
import SymDenotations .SymDenotation
9
9
import Denotations ._
10
10
import Symbols ._
@@ -114,26 +114,10 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
114
114
flags = Private | (if (sym.is(StableRealizable )) EmptyFlags else Mutable ),
115
115
info = fieldType,
116
116
coord = tree.span
117
- ).withAnnotationsCarrying(sym, defn.FieldMetaAnnot )
117
+ ).withAnnotationsCarrying(sym, defn.FieldMetaAnnot , orNoneOf = defn. MetaAnnots )
118
118
.enteredAfter(thisPhase)
119
119
}
120
120
121
- def addAnnotations (denot : Denotation ): Unit =
122
- denot match {
123
- case fieldDenot : SymDenotation if sym.annotations.nonEmpty =>
124
- val cpy = fieldDenot.copySymDenotation()
125
- cpy.annotations = sym.annotations
126
- cpy.installAfter(thisPhase)
127
- case _ => ()
128
- }
129
-
130
- def removeUnwantedAnnotations (denot : SymDenotation , metaAnnotSym : ClassSymbol ): Unit =
131
- if (sym.annotations.nonEmpty) {
132
- val cpy = sym.copySymDenotation()
133
- cpy.filterAnnotations(_.symbol.hasAnnotation(metaAnnotSym))
134
- cpy.installAfter(thisPhase)
135
- }
136
-
137
121
val NoFieldNeeded = Lazy | Deferred | JavaDefined | Inline
138
122
139
123
def erasedBottomTree (sym : Symbol ) =
@@ -183,8 +167,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
183
167
if isErasableBottomField(field, rhsClass) then erasedBottomTree(rhsClass)
184
168
else transformFollowingDeep(ref(field))(using ctx.withOwner(sym))
185
169
val getterDef = cpy.DefDef (tree)(rhs = getterRhs)
186
- addAnnotations(fieldDef.denot)
187
- removeUnwantedAnnotations(sym, defn.GetterMetaAnnot )
170
+ sym.copyAndKeepAnnotationsCarrying(thisPhase, Set (defn.GetterMetaAnnot ))
188
171
Thicket (fieldDef, getterDef)
189
172
else if sym.isSetter then
190
173
if (! sym.is(ParamAccessor )) { val Literal (Constant (())) = tree.rhs: @ unchecked } // This is intended as an assertion
@@ -210,7 +193,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
210
193
then Literal (Constant (()))
211
194
else Assign (ref(field), adaptToField(field, ref(tree.termParamss.head.head.symbol)))
212
195
val setterDef = cpy.DefDef (tree)(rhs = transformFollowingDeep(initializer)(using ctx.withOwner(sym)))
213
- removeUnwantedAnnotations( sym, defn.SetterMetaAnnot )
196
+ sym.copyAndKeepAnnotationsCarrying(thisPhase, Set ( defn.SetterMetaAnnot ) )
214
197
setterDef
215
198
else
216
199
// Curiously, some accessors from Scala2 have ' ' suffixes.
0 commit comments