From ea0d4e4e4f05b6b71f4b230ab4b92431cb902e49 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sat, 4 Oct 2014 00:03:46 +0200 Subject: Avoid ClassfileAnnotation warning for @SerialVersionUID @SerialVersionUID is special-cased, the warning doesn't apply. Related to SI-7041. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b498d9e667..aae2d24b32 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1726,7 +1726,10 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if ((clazz isNonBottomSubClass ClassfileAnnotationClass) && (clazz != ClassfileAnnotationClass)) { if (!clazz.owner.isPackageClass) context.error(clazz.pos, "inner classes cannot be classfile annotations") - else restrictionWarning(cdef.pos, unit, + // Ignore @SerialVersionUID, because it is special-cased and handled completely differently. + // It only extends ClassfileAnnotationClass instead of StaticAnnotation to get the enforcement + // of constant argument values "for free". Related to SI-7041. + else if (clazz != SerialVersionUIDAttr) restrictionWarning(cdef.pos, unit, """|subclassing Classfile does not |make your annotation visible at runtime. If that is what |you want, you must write the annotation class in Java.""".stripMargin) -- cgit v1.2.3