8293519: deprecation warnings should be emitted for uses of annotation methods inside other annotations

Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2023-01-31 18:20:11 +00:00
parent 4bef233a4a
commit 6beadbbe9f
3 changed files with 20 additions and 0 deletions

View File

@ -521,6 +521,7 @@ public class Annotate {
left.name, List.nil(), null);
left.sym = method;
left.type = method.type;
chk.checkDeprecated(left, env.info.scope.owner, method);
if (method.owner != thisAnnotationType.tsym && !badAnnotation)
log.error(left.pos(), Errors.NoAnnotationMember(left.name, thisAnnotationType));
Type resultType = method.type.getReturnType();

View File

@ -0,0 +1,15 @@
/*
* @test /nodynamiccopyright/
* @bug 8293519
* @summary deprecation warnings should be emitted for uses of annotation methods inside other annotations
* @compile/fail/ref=DeprecationWarningTest.out -deprecation -Werror -XDrawDiagnostics DeprecationWarningTest.java
*/
// both classes can't be inside the same outermost class or the compiler wont emit the warning as `9.6.4.6 @Deprecated` mandates
@interface Anno {
@Deprecated
boolean b() default false;
}
@Anno(b = true)
class Foo {}

View File

@ -0,0 +1,4 @@
DeprecationWarningTest.java:14:7: compiler.warn.has.been.deprecated: b(), Anno
- compiler.err.warnings.and.werror
1 error
1 warning