mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-23 16:55:09 +00:00
8069094: SuppressWarnings(\"deprecation\") not respected on default clause on annotation declarations
Properly deferring warnings that are reported during entering of annotation's default value. Reviewed-by: mcimadamore
This commit is contained in:
parent
671f90ddc7
commit
8944d18416
@ -227,7 +227,7 @@ public class MemberEnter extends JCTree.Visitor {
|
||||
annotate.annotateTypeLater(tree, localEnv, m, tree.pos());
|
||||
|
||||
if (tree.defaultValue != null)
|
||||
annotateDefaultValueLater(tree.defaultValue, localEnv, m);
|
||||
annotateDefaultValueLater(tree.defaultValue, localEnv, m, tree.pos());
|
||||
}
|
||||
|
||||
/** Create a fresh environment for method bodies.
|
||||
@ -438,7 +438,8 @@ public class MemberEnter extends JCTree.Visitor {
|
||||
/** Queue processing of an attribute default value. */
|
||||
void annotateDefaultValueLater(final JCExpression defaultValue,
|
||||
final Env<AttrContext> localEnv,
|
||||
final MethodSymbol m) {
|
||||
final MethodSymbol m,
|
||||
final DiagnosticPosition deferPos) {
|
||||
annotate.normal(new Annotate.Worker() {
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -449,9 +450,11 @@ public class MemberEnter extends JCTree.Visitor {
|
||||
@Override
|
||||
public void run() {
|
||||
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
|
||||
DiagnosticPosition prevLintPos = deferredLintHandler.setPos(deferPos);
|
||||
try {
|
||||
enterDefaultValue(defaultValue, localEnv, m);
|
||||
} finally {
|
||||
deferredLintHandler.setPos(prevLintPos);
|
||||
log.useSource(prev);
|
||||
}
|
||||
}
|
||||
|
||||
17
langtools/test/tools/javac/warnings/suppress/T8069094.java
Normal file
17
langtools/test/tools/javac/warnings/suppress/T8069094.java
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8069094
|
||||
* @summary Verify that \\@SuppressWarnings("unchecked") works correctly for annotation default values
|
||||
* @build VerifySuppressWarnings
|
||||
* @compile/ref=T8069094.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast T8069094.java
|
||||
* @run main VerifySuppressWarnings T8069094.java
|
||||
*/
|
||||
|
||||
@interface T8069094 {
|
||||
T8069094A foo() default T8069094A.Bar;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
enum T8069094A {
|
||||
Bar
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
T8069094.java:11:5: compiler.warn.has.been.deprecated: T8069094A, compiler.misc.unnamed.package
|
||||
T8069094.java:11:29: compiler.warn.has.been.deprecated: T8069094A, compiler.misc.unnamed.package
|
||||
2 warnings
|
||||
Loading…
x
Reference in New Issue
Block a user