8175198: Javac incorrectly allows receiver parameters in annotation methods
Reviewed-by: mcimadamore
This commit is contained in:
parent
8588a8563d
commit
50644d73dd
@ -974,8 +974,11 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
ClassSymbol owner = env.enclClass.sym;
|
||||
if ((owner.flags() & ANNOTATION) != 0 &&
|
||||
tree.params.nonEmpty())
|
||||
log.error(tree.params.head.pos(),
|
||||
(tree.params.nonEmpty() ||
|
||||
tree.recvparam != null))
|
||||
log.error(tree.params.nonEmpty() ?
|
||||
tree.params.head.pos() :
|
||||
tree.recvparam.pos(),
|
||||
"intf.annotation.members.cant.have.params");
|
||||
|
||||
// Attribute all value parameters.
|
||||
|
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8175198
|
||||
* @summary Javac incorrectly allows receiver parameters in annotation methods
|
||||
* @compile/fail/ref=AnnotationsAndFormalParamsTest.out -XDrawDiagnostics -Werror -Xlint:unchecked AnnotationsAndFormalParamsTest.java
|
||||
*/
|
||||
|
||||
@interface AnnotationsAndFormalParamsTest {
|
||||
int value(int i);
|
||||
int foo(AnnotationsAndFormalParamsTest this);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
AnnotationsAndFormalParamsTest.java:9:19: compiler.err.intf.annotation.members.cant.have.params
|
||||
AnnotationsAndFormalParamsTest.java:10:44: compiler.err.intf.annotation.members.cant.have.params
|
||||
2 errors
|
Loading…
Reference in New Issue
Block a user