开发者

Scala Annotation List?

开发者 https://www.devze.com 2023-01-13 00:04 出处:网络
I wanted to ask if there is a list of annotations for Scala 2.8.0? I stumbled upon @inline and @specialized but it would be nice if there is a complete list which also explains what they do exactly.

I wanted to ask if there is a list of annotations for Scala 2.8.0? I stumbled upon @inline and @specialized but it would be nice if there is a complete list which also explains what they do exactly.

If such a list doesn't exist: Are there some annotation开发者_如何学Pythons one should be familiar with?


Tour of Scala Annotations: http://www.scala-lang.org/node/106

Internals of Scala Annotations: http://www.scala-lang.org/sid/5

The tour is out of date now. There are several more annotations built into Scala now.

The Known Subclasses section of the Scaladoc for scala.annotation.Annotation provides a fairly significant list (below is as of 2.12.1):

SerialVersionUID, ClassfileAnnotation, StaticAnnotation, TypeConstraint, compileTimeOnly, elidable, implicitAmbiguous, implicitNotFound, beanGetter, beanSetter, companionClass, companionMethod, companionObject, field, getter, languageFeature, param, setter, strictfp, switch, tailrec, uncheckedStable, uncheckedVariance, unspecialized, varargs, BeanDescription, BeanDisplayName, BeanInfoSkip, BeanProperty, BooleanBeanProperty, deprecated, deprecatedInheritance, deprecatedName, deprecatedOverriding, inline, native, noinline, specialized, throws, transient, unchecked, volatile, BeanInfo, remote

SOURCE: http://www.scala-lang.org/api/current/scala/annotation/Annotation.html


It's easy enough to get a list of all Scala annotations. Just go to http://www.scala-lang.org/api/current/scala/annotation/Annotation.html and click on "Known subclasses". Today, I get

BeanDescription, BeanDisplayName, BeanInfo, BeanInfoSkip, BeanProperty, BooleanBeanProperty, ClassfileAnnotation, SerialVersionUID, StaticAnnotation, TypeConstraint, beanGetter, beanSetter, cloneable, cpsParam, deprecated, deprecatedName, elidable, field, getter, implicitNotFound, inline, native, noinline, param, remote, serializable, setter, specialized, strictfp, switch, tailrec, throws, transient, unchecked, uncheckedStable, uncheckedVariance, varargs, volatile


To answer my own question:

The official "The Scala Language Specification Version 2.8" actually also has a nice list of annotations in it with some explanation. (Chapter 11, page 133ff.)

Although for example @inline isn't listed there. So it seems not to be complete either.


See exhaustive annotation list for Scala 2.12+. Head link, will stay up to date.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号