Skip to content

Commit 0bd5087

Browse files
committed
Reuse SymUtils.withAnnotationsCarrying
1 parent e35dc2a commit 0bd5087

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ast.tpd._
66
import Annotations._
77
import Contexts._
88
import Symbols.newSymbol
9+
import SymUtils.*
910
import Decorators._
1011
import Flags._
1112
import Names._
@@ -34,10 +35,7 @@ class BeanProperties(thisPhase: DenotTransformer):
3435
info = MethodType(Nil, valDef.denot.info),
3536
coord = annot.tree.span
3637
).enteredAfter(thisPhase).asTerm
37-
val annots = valDef.symbol.annotations.filterConserve { a =>
38-
a.hasOneOfMetaAnnotation(defn.BeanGetterMetaAnnot)
39-
}
40-
meth.addAnnotations(annots)
38+
.withAnnotationsCarrying(valDef.symbol, defn.BeanGetterMetaAnnot)
4139
val body: Tree = ref(valDef.symbol)
4240
DefDef(meth, body).withSpan(meth.span)
4341

@@ -51,10 +49,7 @@ class BeanProperties(thisPhase: DenotTransformer):
5149
info = MethodType(valDef.name :: Nil, valDef.denot.info :: Nil, defn.UnitType),
5250
coord = annot.tree.span
5351
).enteredAfter(thisPhase).asTerm
54-
val annots = valDef.symbol.annotations.filterConserve { a =>
55-
a.hasOneOfMetaAnnotation(defn.BeanSetterMetaAnnot)
56-
}
57-
meth.addAnnotations(annots)
52+
.withAnnotationsCarrying(valDef.symbol, defn.BeanSetterMetaAnnot)
5853
def body(params: List[List[Tree]]): Tree = Assign(ref(valDef.symbol), params.head.head)
5954
DefDef(meth, body).withSpan(meth.span)
6055
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
125125
def removeUnwantedAnnotations(denot: SymDenotation, metaAnnotSym: ClassSymbol): Unit =
126126
if (sym.annotations.nonEmpty) {
127127
val cpy = sym.copySymDenotation()
128-
cpy.filterAnnotations(annot => annot.hasOneOfMetaAnnotation(metaAnnotSym))
128+
cpy.filterAnnotations(_.hasOneOfMetaAnnotation(metaAnnotSym))
129129
cpy.installAfter(thisPhase)
130130
}
131131

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ object SymUtils:
271271
self.isAllOf(EnumCase, butNot = JavaDefined)
272272

273273
def annotationsCarrying(meta: ClassSymbol)(using Context): List[Annotation] =
274-
self.annotations.filter(_.hasOneOfMetaAnnotation(meta))
274+
self.annotations.filterConserve(_.hasOneOfMetaAnnotation(meta))
275275

276276
def withAnnotationsCarrying(from: Symbol, meta: ClassSymbol)(using Context): self.type = {
277277
self.addAnnotations(from.annotationsCarrying(meta))

0 commit comments

Comments
 (0)