@@ -4,7 +4,7 @@ package transform
44import core ._
55import DenotTransformers ._
66import Contexts ._
7- import Phases .phaseOf
7+ import Phases .*
88import SymDenotations .SymDenotation
99import Denotations ._
1010import Symbols ._
@@ -114,26 +114,10 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
114114 flags = Private | (if (sym.is(StableRealizable )) EmptyFlags else Mutable ),
115115 info = fieldType,
116116 coord = tree.span
117- ).withAnnotationsCarrying(sym, defn.FieldMetaAnnot )
117+ ).withAnnotationsCarrying(sym, defn.FieldMetaAnnot , orNoneOf = defn. MetaAnnots )
118118 .enteredAfter(thisPhase)
119119 }
120120
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-
137121 val NoFieldNeeded = Lazy | Deferred | JavaDefined | Inline
138122
139123 def erasedBottomTree (sym : Symbol ) =
@@ -183,8 +167,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
183167 if isErasableBottomField(field, rhsClass) then erasedBottomTree(rhsClass)
184168 else transformFollowingDeep(ref(field))(using ctx.withOwner(sym))
185169 val getterDef = cpy.DefDef (tree)(rhs = getterRhs)
186- addAnnotations(fieldDef.denot)
187- removeUnwantedAnnotations(sym, defn.GetterMetaAnnot )
170+ sym.copyAndKeepAnnotationsCarrying(thisPhase, Set (defn.GetterMetaAnnot ))
188171 Thicket (fieldDef, getterDef)
189172 else if sym.isSetter then
190173 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 =>
210193 then Literal (Constant (()))
211194 else Assign (ref(field), adaptToField(field, ref(tree.termParamss.head.head.symbol)))
212195 val setterDef = cpy.DefDef (tree)(rhs = transformFollowingDeep(initializer)(using ctx.withOwner(sym)))
213- removeUnwantedAnnotations( sym, defn.SetterMetaAnnot )
196+ sym.copyAndKeepAnnotationsCarrying(thisPhase, Set ( defn.SetterMetaAnnot ) )
214197 setterDef
215198 else
216199 // Curiously, some accessors from Scala2 have ' ' suffixes.
0 commit comments