scala - How can I write a trait with @BeanProperty members that must be implemented? -



scala - How can I write a trait with @BeanProperty members that must be implemented? -

i want define trait used java code , hence convenient have java-friendly setters , getters members. @beanproperty annotation me, can't work members left undefined in trait. following:

import scala.beans.beanproperty trait { @beanproperty var usefoo: boolean }

yields warning no valid targets annotation on method usefoo - discarded unused. may specify targets meta-annotations, e.g. @(scala.beans.beanproperty @getter) trait { @beanproperty var usefoo: boolean }

however, not discarded unused. class extending above trait, example

class b extends { var usefoo = false }

is correctly rejected compiler not implement getter , setter of beanproperty. annotating usefoo field in class b @beanproperty makes work expected. however, seems not proper way this, since above warning generated. the documentation meta annotations suggests targets useful if want propagate other annotations onto generated accessors. so, proper way define above trait?

it happens bug in scala 2.11.x: https://issues.scala-lang.org/browse/si-8813

my search didn't turn issue in 2.11.1 warning "no valid targets annotation on method", while in 2.11.2 it's "no valid targets annotation on value"

scala annotations trait

Comments

Popular posts from this blog

php - How to pass multiple values from url -

database - php search bar when I press submit with nothing in the search bar it shows all the data -

ios - How to load .png images from Documents folder of an app -