scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

accessors and bean accessors should be marked synthetic #6821

Open scabug opened 11 years ago

scabug commented 11 years ago

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).

scabug commented 11 years ago

Imported From: https://issues.scala-lang.org/browse/SI-6821?orig=1 Reporter: Lex Spoon (lexspoon) Affected Versions: 2.10.0-RC3

SethTisue commented 6 years ago

is this still an issue in Scala 2.13.0-M3 or newer?