The API docs for Symbol.isSynthetic say the following:
bq. Does this symbol represent a synthetic (i.e. a compiler-generated) entity? Examples of synthetic entities are accessors for vals and vars or mixin constructors in trait implementation classes.
However, I am finding that neither normal accessors nor generated bean properties are marked as synthetic:
$ cat test.scala
class Test {
@scala.reflect.BeanProperty
var beanprop = 0
var normalvar = 0
}
$ scalac -stop:typer -Yshow-syms ~/test.scala
[[symbol layout at end of parser]]
* package scala (final)
[[symbol layout at end of namer]]
* class Test
* package <empty> (final <static>)
package scala (final)
[[symbol layout at end of packageobjects]]
class Test
package <empty> (final <static>)
package scala (final)
[[symbol layout at end of typer]]
* class Int (final abstract)
class Test
* constructor Test
* method beanprop (<accessor>)
* method beanprop_= (<accessor>)
* value beanprop_= (<synthetic>)
* method getBeanprop
* method normalvar (<accessor>)
* method normalvar_= (<accessor>)
* value normalvar_= (<synthetic>)
* method setBeanprop
* value x$1 (<synthetic>)
* value <local Test>
* variable beanprop (private <local>)
* variable normalvar (private <local>)
* class Unit (final abstract)
* constructor Object
package <empty> (final <static>)
package scala (final)
* type AnyRef
For accessors, I can work around it by checking for the accessor flag. For bean properties, it is harder. I guess I could check for the BeanProperty, essentially trying to reverse the transformation and seeing if I succeed. I'm not positive that is reliable, though, especially in the face of plausible future changes to the compiler.
Intuitively, isSynthetic should be turned on for these guys. Whoever wrote the doc seems to have had the same intuition.
As a possible clarification, I am talking here only about Scala's reflection API. The Java bytecode attribute of the same name should be left alone (#1128).
The API docs for Symbol.isSynthetic say the following:
bq. Does this symbol represent a synthetic (i.e. a compiler-generated) entity? Examples of synthetic entities are accessors for vals and vars or mixin constructors in trait implementation classes.
However, I am finding that neither normal accessors nor generated bean properties are marked as synthetic:
For accessors, I can work around it by checking for the accessor flag. For bean properties, it is harder. I guess I could check for the BeanProperty, essentially trying to reverse the transformation and seeing if I succeed. I'm not positive that is reliable, though, especially in the face of plausible future changes to the compiler.
Intuitively, isSynthetic should be turned on for these guys. Whoever wrote the doc seems to have had the same intuition.
As a possible clarification, I am talking here only about Scala's reflection API. The Java bytecode attribute of the same name should be left alone (#1128).