8145987: Assertion failure when compiling stream with type annotation
Reviewed-by: jlahoda
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Sun Jan 24 11:44:10 2016 +0100
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Mon Jan 25 15:49:50 2016 +0530
@@ -1017,7 +1017,7 @@
case METHOD_INVOCATION: {
JCMethodInvocation invocation = (JCMethodInvocation)frame;
if (!invocation.typeargs.contains(tree)) {
- throw new AssertionError("{" + tree + "} is not an argument in the invocation: " + invocation);
+ return TypeAnnotationPosition.unknown;
}
MethodSymbol exsym = (MethodSymbol) TreeInfo.symbol(invocation.getMethodSelect());
final int type_index = invocation.typeargs.indexOf(tree);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedMethodSelectorTest.java Mon Jan 25 15:49:50 2016 +0530
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8145987
+ * @summary Assertion failure when compiling stream with type annotation
+ * @compile/fail/ref=AnnotatedMethodSelectorTest.out -XDrawDiagnostics AnnotatedMethodSelectorTest.java
+ */
+
+
+class AnnotatedMethodSelectorTest {
+ @interface A {}
+ static public void main(String... args) {
+ java.util.@A() Arrays.stream(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedMethodSelectorTest.out Mon Jan 25 15:49:50 2016 +0530
@@ -0,0 +1,2 @@
+AnnotatedMethodSelectorTest.java:12:19: compiler.err.annotation.type.not.applicable.to.type: AnnotatedMethodSelectorTest.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedMethodSelectorTest2.java Mon Jan 25 15:49:50 2016 +0530
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8145987
+ * @summary Assertion failure when compiling stream with type annotation
+ * @compile/fail/ref=AnnotatedMethodSelectorTest2.out -XDrawDiagnostics AnnotatedMethodSelectorTest2.java
+ */
+
+class AnnotatedMethodSelectorTest2<T> {
+ @interface A {}
+ class Inner {}
+ static public void main(String... args) {
+ new AnnotatedMethodSelectorTest2<@A String>() {
+ java.util.@A List l;
+ }.hashCode();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedMethodSelectorTest2.out Mon Jan 25 15:49:50 2016 +0530
@@ -0,0 +1,3 @@
+AnnotatedMethodSelectorTest2.java:12:42: compiler.err.annotation.type.not.applicable.to.type: AnnotatedMethodSelectorTest2.A
+AnnotatedMethodSelectorTest2.java:13:23: compiler.err.annotation.type.not.applicable.to.type: AnnotatedMethodSelectorTest2.A
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedMethodSelectorTest3.java Mon Jan 25 15:49:50 2016 +0530
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8145987
+ * @summary Assertion failure when compiling stream with type annotation
+ * @compile/fail/ref=AnnotatedMethodSelectorTest3.out -XDrawDiagnostics AnnotatedMethodSelectorTest3.java
+ */
+
+
+class AnnotatedMethodSelectorTest3 {
+ @interface A {}
+ static <T> AnnotatedMethodSelectorTest3 id() {
+ return null;
+ }
+ static public void main(String... args) {
+ AnnotatedMethodSelectorTest3.<@A String> id().id().id().id().id();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedMethodSelectorTest3.out Mon Jan 25 15:49:50 2016 +0530
@@ -0,0 +1,2 @@
+AnnotatedMethodSelectorTest3.java:15:39: compiler.err.annotation.type.not.applicable.to.type: AnnotatedMethodSelectorTest3.A
+1 error