Skip to content

Commit f6b18ac

Browse files
committed
Add filtering out synthetic accessors from unpickled templates
1 parent cd7006e commit f6b18ac

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,15 @@ class TreeUnpickler(reader: TastyReader,
582582
else
583583
newSymbol(ctx.owner, name, flags, completer, privateWithin, coord)
584584
}
585-
sym.annotations = annotFns.map(_(sym.owner))
585+
val annots = annotFns.map(_(sym.owner))
586+
sym.annotations = annots
586587
if sym.isOpaqueAlias then sym.setFlag(Deferred)
588+
val isSyntheticBeanAccessor = flags.isAllOf(Method | Synthetic) &&
589+
annots.exists(a => a.matches(defn.BeanPropertyAnnot) || a.matches(defn.BooleanBeanPropertyAnnot))
587590
val isScala2MacroDefinedInScala3 = flags.is(Macro, butNot = Inline) && flags.is(Erased)
588591
ctx.owner match {
589-
case cls: ClassSymbol if !isScala2MacroDefinedInScala3 || cls == defn.StringContextClass =>
590-
// Enter all members of classes that are not Scala 2 macros.
592+
case cls: ClassSymbol if (!isScala2MacroDefinedInScala3 || cls == defn.StringContextClass) && !isSyntheticBeanAccessor =>
593+
// Enter all members of classes that are not Scala 2 macros or synthetic accessors.
591594
//
592595
// For `StringContext`, enter `s`, `f` and `raw`
593596
// These definitions will be entered when defined in Scala 2. It is fine to enter them
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class A:
2+
@scala.beans.BeanProperty val x = 6
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class B(val a: A):
2+
def x = a.getX() // error

0 commit comments

Comments
 (0)