langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 31560 3a71b9271010
parent 31212 edf65e25e066
child 31751 ec251536a004
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jul 05 20:40:53 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jul 08 19:01:57 2015 +0530
@@ -4140,12 +4140,7 @@
 
     public void visitAnnotatedType(JCAnnotatedType tree) {
         attribAnnotationTypes(tree.annotations, env);
-        JCExpression underlyingTypeTree = tree.getUnderlyingType();
-        Type underlyingType = attribTree(underlyingTypeTree, env,
-                                               new ResultInfo(KindSelector.TYP_PCK, Type.noType));
-        if (!chk.checkAnnotableType(underlyingType, tree.annotations, underlyingTypeTree.pos())) {
-            underlyingType = underlyingTypeTree.type = syms.errType;
-        }
+        Type underlyingType = attribType(tree.underlyingType, env);
         Type annotatedType = underlyingType.annotatedType(Annotations.TO_BE_SET);
 
         if (!env.info.isNewClass)
@@ -4636,7 +4631,16 @@
                     }
                 } else if (enclTr.hasTag(ANNOTATED_TYPE)) {
                     JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr;
-                    if (!chk.checkAnnotableType(enclTy, at.getAnnotations(), at.underlyingType.pos())) {
+                    if (enclTy == null || enclTy.hasTag(NONE)) {
+                        if (at.getAnnotations().size() == 1) {
+                            log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute);
+                        } else {
+                            ListBuffer<Attribute.Compound> comps = new ListBuffer<>();
+                            for (JCAnnotation an : at.getAnnotations()) {
+                                comps.add(an.attribute);
+                            }
+                            log.error(at.underlyingType.pos(), "cant.type.annotate.scoping", comps.toList());
+                        }
                         repeat = false;
                     }
                     enclTr = at.underlyingType;