changeset 56945:63cb5c34b41e amber-demo-II

Automatic merge with records-and-sealed
author mcimadamore
date Wed, 17 Jul 2019 18:50:40 +0000
parents fd2debbca81b d5b1f8f224cd
children 36abd263dca2
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
diffstat 3 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 17 14:30:41 2019 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 17 18:50:40 2019 +0000
@@ -2864,7 +2864,12 @@
             Name[] targets = getTargetNames(a, s);
             boolean appliesToRecords = false;
             for (Name target : targets) {
-                appliesToRecords = target == names.FIELD || target == names.PARAMETER || target == names.METHOD;
+                appliesToRecords =
+                                target == names.FIELD ||
+                                target == names.PARAMETER ||
+                                target == names.METHOD ||
+                                target == names.TYPE_USE ||
+                                target == names.TYPE_PARAMETER;
                 if (appliesToRecords) {
                     break;
                 }
--- a/test/langtools/tools/javac/records/annotations/BadAnnotations.java	Wed Jul 17 14:30:41 2019 +0000
+++ b/test/langtools/tools/javac/records/annotations/BadAnnotations.java	Wed Jul 17 18:50:40 2019 +0000
@@ -4,12 +4,10 @@
  * @compile/fail/ref=BadAnnotations.out -XDrawDiagnostics BadAnnotations.java
  */
 
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
 
 class BadAnnotations {
+    // negative cases
     @Target({ ElementType.CONSTRUCTOR })
     @interface Foo1 {}
     record R1(@Foo1 int i) {}
@@ -46,4 +44,13 @@
     // no target applies to all
     @interface Foo9 {}
     record R9(@Foo9 int i) {}
+
+    // type annotations are allowed too
+    @Target({ ElementType.TYPE_USE })
+    @interface Foo10 {}
+    record R10(@Foo10 int i) {}
+
+    @Target({ ElementType.TYPE_PARAMETER })
+    @interface Foo11 {}
+    record R11(@Foo11 int i) {}
 }
--- a/test/langtools/tools/javac/records/annotations/BadAnnotations.out	Wed Jul 17 14:30:41 2019 +0000
+++ b/test/langtools/tools/javac/records/annotations/BadAnnotations.out	Wed Jul 17 18:50:40 2019 +0000
@@ -1,6 +1,6 @@
-BadAnnotations.java:15:15: compiler.err.annotation.type.not.applicable
-BadAnnotations.java:19:15: compiler.err.annotation.type.not.applicable
-BadAnnotations.java:23:15: compiler.err.annotation.type.not.applicable
-BadAnnotations.java:27:15: compiler.err.annotation.type.not.applicable
-BadAnnotations.java:31:15: compiler.err.annotation.type.not.applicable
+BadAnnotations.java:13:15: compiler.err.annotation.type.not.applicable
+BadAnnotations.java:17:15: compiler.err.annotation.type.not.applicable
+BadAnnotations.java:21:15: compiler.err.annotation.type.not.applicable
+BadAnnotations.java:25:15: compiler.err.annotation.type.not.applicable
+BadAnnotations.java:29:15: compiler.err.annotation.type.not.applicable
 5 errors