8334055: Unhelpful 'required: reference' diagnostics after JDK-8043226
Reviewed-by: vromero
This commit is contained in:
parent
5100303c6c
commit
9eb611e7f0
@ -5241,14 +5241,7 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
public void visitAnnotatedType(JCAnnotatedType tree) {
|
||||
attribAnnotationTypes(tree.annotations, env);
|
||||
Type underlyingType =
|
||||
attribTree(tree.underlyingType, env, new ResultInfo(KindSelector.TYP_PCK, Type.noType));
|
||||
if (underlyingType.hasTag(PACKAGE)) {
|
||||
// Type annotations are not admissible on packages, but we handle packages here to
|
||||
// report better diagnostics later in validateAnnotatedType.
|
||||
result = tree.type = underlyingType;
|
||||
return;
|
||||
}
|
||||
Type underlyingType = attribType(tree.underlyingType, env);
|
||||
Type annotatedType = underlyingType.preannotatedType();
|
||||
|
||||
if (!env.info.isNewClass)
|
||||
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8026564 8043226
|
||||
* @summary 8334055
|
||||
* @compile/fail/ref=CantAnnotateMissingSymbol.out -XDrawDiagnostics CantAnnotateMissingSymbol.java
|
||||
*/
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
class CantAnnotateMissingSymbol {
|
||||
List<@TA NoSuch> x;
|
||||
}
|
||||
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@interface TA { }
|
@ -0,0 +1,2 @@
|
||||
CantAnnotateMissingSymbol.java:12:14: compiler.err.cant.resolve.location: kindname.class, NoSuch, , , (compiler.misc.location: kindname.class, CantAnnotateMissingSymbol, null)
|
||||
1 error
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8026564 8043226
|
||||
* @bug 8026564 8043226 8334055
|
||||
* @summary The parts of a fully-qualified type can't be annotated.
|
||||
* @author Werner Dietl
|
||||
* @compile/fail/ref=CantAnnotatePackages.out -XDrawDiagnostics CantAnnotatePackages.java
|
||||
|
@ -1,5 +1,5 @@
|
||||
CantAnnotatePackages.java:16:14: compiler.err.cant.resolve.location: kindname.class, java, , , (compiler.misc.location: kindname.class, CantAnnotatePackages, null)
|
||||
CantAnnotatePackages.java:17:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotatePackages.java:18:14: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotatePackages.java:14:18: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), java.lang, @TA java.lang.Object
|
||||
CantAnnotatePackages.java:16:14: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), java.lang, @TA java.lang.Object
|
||||
CantAnnotatePackages.java:17:9: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), java.lang, @TA java.lang.Object
|
||||
CantAnnotatePackages.java:18:14: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), java.lang, @TA java.lang.Object
|
||||
4 errors
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8006733 8006775 8043226
|
||||
* @bug 8006733 8006775 8043226 8334055
|
||||
* @summary Ensure behavior for nested types is correct.
|
||||
* @author Werner Dietl
|
||||
* @compile/fail/ref=CantAnnotateScoping.out -XDrawDiagnostics CantAnnotateScoping.java
|
||||
|
@ -1,13 +1,12 @@
|
||||
CantAnnotateScoping.java:68:18: compiler.err.doesnt.exist: java.XXX
|
||||
CantAnnotateScoping.java:63:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotateScoping.java:68:9: compiler.err.cant.resolve.location: kindname.class, XXX, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotateScoping.java:71:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null)
|
||||
CantAnnotateScoping.java:38:14: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), Test.Outer, @TA Test.Outer.SInner
|
||||
CantAnnotateScoping.java:51:18: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), java.lang, @TA java.lang.Object
|
||||
CantAnnotateScoping.java:60:37: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation: @TA,@TA2), java.lang, @DTA @TA @TA2 java.lang.Object
|
||||
CantAnnotateScoping.java:40:14: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), Test.Outer, @TA Test.Outer.SInner
|
||||
CantAnnotateScoping.java:63:11: compiler.err.annotation.type.not.applicable.to.type: DA
|
||||
CantAnnotateScoping.java:68:11: compiler.err.annotation.type.not.applicable.to.type: DA
|
||||
CantAnnotateScoping.java:71:9: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), java.lang, @TA java.lang.Object
|
||||
CantAnnotateScoping.java:44:34: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation: @TA,@TA2), Test.Outer, @TA @TA2 Test.Outer.SInner
|
||||
CantAnnotateScoping.java:44:25: compiler.err.annotation.type.not.applicable.to.type: DA
|
||||
CantAnnotateScoping.java:48:38: compiler.err.type.annotation.inadmissible: (compiler.misc.type.annotation.1: @TA), Test.Outer, @TA Test.Outer.SInner
|
||||
CantAnnotateScoping.java:48:34: compiler.err.annotation.type.not.applicable.to.type: DA
|
||||
12 errors
|
||||
11 errors
|
||||
|
Loading…
Reference in New Issue
Block a user