Skip to content

Commit 9f08c03

Browse files
committed
Fix missing coordinates
1 parent a0c523d commit 9f08c03

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package transform
33

44
import core._
55
import ast.tpd._
6+
import Annotations._
67
import Contexts._
78
import SymDenotations._
89
import Symbols.newSymbol
910
import Decorators._
1011
import Flags._
1112
import Names._
1213
import Types._
14+
import util.Spans._
1315

1416
import DenotTransformers._
1517

@@ -24,26 +26,28 @@ class BeanProperties(thisPhase: DenotTransformer):
2426
def generateAccessors(valDef: ValDef)(using Context): List[Tree] =
2527
import Symbols.defn
2628

27-
def generateGetter(valDef: ValDef)(using Context) : Tree =
28-
val prefix = if valDef.symbol.denot.hasAnnotation(defn.BooleanBeanPropertyAnnot) then "is" else "get"
29+
def generateGetter(valDef: ValDef, annot: Annotation)(using Context) : Tree =
30+
val prefix = if annot matches defn.BooleanBeanPropertyAnnot then "is" else "get"
2931
val meth = newSymbol(
3032
owner = ctx.owner,
3133
name = prefixedName(prefix, valDef.name),
3234
flags = Method | Synthetic,
33-
info = MethodType(Nil, valDef.denot.info))
34-
.enteredAfter(thisPhase).asTerm
35+
info = MethodType(Nil, valDef.denot.info),
36+
coord = annot.tree.span
37+
).enteredAfter(thisPhase).asTerm
3538
meth.addAnnotations(valDef.symbol.annotations)
3639
val body: Tree = ref(valDef.symbol)
3740
DefDef(meth, body)
3841

39-
def maybeGenerateSetter(valDef: ValDef)(using Context): Option[Tree] =
42+
def maybeGenerateSetter(valDef: ValDef, annot: Annotation)(using Context): Option[Tree] =
4043
Option.when(valDef.denot.asSymDenotation.flags.is(Mutable)) {
4144
val owner = ctx.owner
4245
val meth = newSymbol(
4346
owner,
4447
name = prefixedName("set", valDef.name),
4548
flags = Method | Permanent | Synthetic,
46-
info = MethodType(valDef.name :: Nil, valDef.denot.info :: Nil, defn.UnitType)
49+
info = MethodType(valDef.name :: Nil, valDef.denot.info :: Nil, defn.UnitType),
50+
coord = annot.tree.span
4751
).enteredAfter(thisPhase).asTerm
4852
meth.addAnnotations(valDef.symbol.annotations)
4953
def body(params: List[List[Tree]]): Tree = Assign(ref(valDef.symbol), params.head.head)
@@ -54,7 +58,9 @@ class BeanProperties(thisPhase: DenotTransformer):
5458
(prefix + valName.lastPart.toString.capitalize).toTermName
5559

5660
val symbol = valDef.denot.symbol
57-
if symbol.hasAnnotation(defn.BeanPropertyAnnot) || symbol.hasAnnotation(defn.BooleanBeanPropertyAnnot) then
58-
generateGetter(valDef) +: maybeGenerateSetter(valDef) ++: Nil
59-
else Nil
61+
symbol.getAnnotation(defn.BeanPropertyAnnot)
62+
.orElse(symbol.getAnnotation(defn.BooleanBeanPropertyAnnot))
63+
.toList.flatMap { annot =>
64+
generateGetter(valDef, annot) +: maybeGenerateSetter(valDef, annot) ++: Nil
65+
}
6066
end generateAccessors

0 commit comments

Comments
 (0)