Skip to content

Commit 382b33e

Browse files
committed
Merge pull request scala#4028 from soc/topic/serialversionuid-spam
Avoid ClassfileAnnotation warning for @serialversionuid
2 parents 0940f19 + ea0d4e4 commit 382b33e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,10 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
17261726
if ((clazz isNonBottomSubClass ClassfileAnnotationClass) && (clazz != ClassfileAnnotationClass)) {
17271727
if (!clazz.owner.isPackageClass)
17281728
context.error(clazz.pos, "inner classes cannot be classfile annotations")
1729-
else restrictionWarning(cdef.pos, unit,
1729+
// Ignore @SerialVersionUID, because it is special-cased and handled completely differently.
1730+
// It only extends ClassfileAnnotationClass instead of StaticAnnotation to get the enforcement
1731+
// of constant argument values "for free". Related to SI-7041.
1732+
else if (clazz != SerialVersionUIDAttr) restrictionWarning(cdef.pos, unit,
17301733
"""|subclassing Classfile does not
17311734
|make your annotation visible at runtime. If that is what
17321735
|you want, you must write the annotation class in Java.""".stripMargin)

0 commit comments

Comments
 (0)