8145987: Assertion failure when compiling stream with type annotation

Reviewed-by: jlahoda
This commit is contained in:
Srikanth Adayapalam 2016-01-25 15:49:50 +05:30
parent 7d17c7744d
commit 78651a213e
7 changed files with 55 additions and 1 deletions

View File

@ -1017,7 +1017,7 @@ public class TypeAnnotations {
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);

View File

@ -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);
}
}

View File

@ -0,0 +1,2 @@
AnnotatedMethodSelectorTest.java:12:19: compiler.err.annotation.type.not.applicable.to.type: AnnotatedMethodSelectorTest.A
1 error

View File

@ -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();
}
}

View File

@ -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

View File

@ -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();
}
}

View File

@ -0,0 +1,2 @@
AnnotatedMethodSelectorTest3.java:15:39: compiler.err.annotation.type.not.applicable.to.type: AnnotatedMethodSelectorTest3.A
1 error