@@ -108,27 +108,16 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
108108 if (sym.isGetter) sym.info.resultType
109109 else /* sym.isSetter*/ sym.info.firstParamTypes.head
110110
111- val fieldSym = newSymbol(
111+ newSymbol(
112112 owner = ctx.owner,
113113 name = sym.name.asTermName.fieldName,
114114 flags = Private | (if (sym.is(StableRealizable )) EmptyFlags else Mutable ),
115115 info = fieldType,
116116 coord = tree.span
117- )
118- fieldSym.annotations = sym.annotations.filterConserve { annot =>
119- annot.hasOneOfMetaAnnotation(defn.FieldMetaAnnot )
120- || ! annot.hasOneOfMetaAnnotation(defn.MetaAnnots .toList* )
121- }
122- fieldSym.enteredAfter(thisPhase)
117+ ).withAnnotationsCarrying(sym, defn.FieldMetaAnnot , orNoneOf = defn.MetaAnnots )
118+ .enteredAfter(thisPhase)
123119 }
124120
125- def removeUnwantedAnnotations (denot : SymDenotation , metaAnnotSym : ClassSymbol ): Unit =
126- if (sym.annotations.nonEmpty) {
127- val cpy = sym.copySymDenotation()
128- cpy.filterAnnotations(_.hasOneOfMetaAnnotation(metaAnnotSym))
129- cpy.installAfter(thisPhase)
130- }
131-
132121 val NoFieldNeeded = Lazy | Deferred | JavaDefined | Inline
133122
134123 def erasedBottomTree (sym : Symbol ) =
@@ -178,7 +167,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
178167 if isErasableBottomField(field, rhsClass) then erasedBottomTree(rhsClass)
179168 else transformFollowingDeep(ref(field))(using ctx.withOwner(sym))
180169 val getterDef = cpy.DefDef (tree)(rhs = getterRhs)
181- removeUnwantedAnnotations( sym, defn.GetterMetaAnnot )
170+ sym.copyAndKeepAnnotationsCarrying(thisPhase, Set ( defn.GetterMetaAnnot ) )
182171 Thicket (fieldDef, getterDef)
183172 else if sym.isSetter then
184173 if (! sym.is(ParamAccessor )) { val Literal (Constant (())) = tree.rhs: @ unchecked } // This is intended as an assertion
@@ -204,7 +193,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
204193 then Literal (Constant (()))
205194 else Assign (ref(field), adaptToField(field, ref(tree.termParamss.head.head.symbol)))
206195 val setterDef = cpy.DefDef (tree)(rhs = transformFollowingDeep(initializer)(using ctx.withOwner(sym)))
207- removeUnwantedAnnotations( sym, defn.SetterMetaAnnot )
196+ sym.copyAndKeepAnnotationsCarrying(thisPhase, Set ( defn.SetterMetaAnnot ) )
208197 setterDef
209198 else
210199 // Curiously, some accessors from Scala2 have ' ' suffixes.
0 commit comments