diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 5 | ||||
-rw-r--r-- | test/files/neg/annot-nonconst.check | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 1ef6b935e7..c608617ce0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1013,6 +1013,11 @@ trait Typers { self: Analyzer => val impl1 = newTyper(context.make(cdef.impl, clazz, scopeFor(cdef.impl))) .typedTemplate(cdef.impl, parentTypes(cdef.impl)) val impl2 = addSyntheticMethods(impl1, clazz, context) + if (clazz isNonBottomSubClass ClassfileAnnotationClass) + unit.warning (cdef.pos, + "implementation restriction: subclassing Classfile does not\n"+ + "make your annotation visible at runtime. If that is what\n"+ + "you want, you must write the annotation class in Java.") copy.ClassDef(cdef, typedMods, cdef.name, tparams1, impl2) .setType(NoType) } diff --git a/test/files/neg/annot-nonconst.check b/test/files/neg/annot-nonconst.check index 197ff930a5..ef1a72adf2 100644 --- a/test/files/neg/annot-nonconst.check +++ b/test/files/neg/annot-nonconst.check @@ -1,4 +1,10 @@ +annot-nonconst.scala:1: warning: implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class Length(n: Int) extends ClassfileAnnotation + ^ annot-nonconst.scala:5: error: attribute argument needs to be a constant; found: Test.this.n @Length(n) def foo = "foo" ^ +one warning found one error found |