894N/A/*
894N/A * @test /nodynamiccopyright/
894N/A * @bug 7015430
894N/A *
894N/A * @summary Incorrect thrown type determined for unchecked invocations
894N/A * @author Daniel Smith
894N/A * @compile/fail/ref=T7015430.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
894N/A *
894N/A */
894N/A
894N/Aclass T7015430 {
894N/A static <E extends Exception> Iterable<E> empty(Iterable<E> arg) throws E {
894N/A return null;
894N/A }
894N/A
894N/A <E extends Exception> T7015430(Iterable<E> arg) throws E { }
894N/A
894N/A static <E extends Exception> Iterable<E> empty2(Iterable x) throws E {
894N/A return null;
894N/A }
894N/A
894N/A static class Foo<X extends Exception> {
894N/A Foo() throws X {}
894N/A }
894N/A
894N/A /**
894N/A * Method invocation, no unchecked
894N/A * inferred: RuntimeException - should pass
894N/A */
894N/A void m1() {
894N/A Iterable<RuntimeException> i = java.util.Collections.emptyList();
894N/A empty(i);
894N/A }
894N/A
894N/A /**
894N/A * Method invocation, unchecked, inferred arguments
894N/A * inferred: Exception - should fail
894N/A */
894N/A void m2() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A empty(i);
894N/A }
894N/A
894N/A /**
894N/A * Method invocation, unchecked, explicit arguments
894N/A * inferred: RuntimeException - should pass
894N/A */
894N/A void m3() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A T7015430.<RuntimeException>empty(i);
894N/A }
894N/A
894N/A /**
894N/A * Constructor invocation, no unchecked
894N/A * inferred: RuntimeException - should pass
894N/A */
894N/A void m4() {
894N/A Iterable<RuntimeException> i = java.util.Collections.emptyList();
894N/A new T7015430(i);
894N/A }
894N/A
894N/A /**
894N/A * Constructor invocation, unchecked, inferred arguments
894N/A * inferred: Exception - should fail
894N/A */
894N/A void m5() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A new T7015430(i);
894N/A }
894N/A
894N/A /**
894N/A * Constructor invocation, unchecked, explicit arguments
894N/A * inferred: RuntimeException - should pass
894N/A */
894N/A void m6() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A new <RuntimeException>T7015430(i);
894N/A }
894N/A
894N/A /**
894N/A * Method invocation, no unchecked, inferred arguments
894N/A * inferred: RuntimeException - should pass
894N/A */
894N/A void m7() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A Iterable<RuntimeException> e = empty2(i);
894N/A }
894N/A
894N/A /**
894N/A * Method invocation, no unchecked, inferred arguments
894N/A * inferred: Exception - should fail
894N/A */
894N/A void m8() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A empty2(i);
894N/A }
894N/A
894N/A /**
894N/A * Constructor invocation, unchecked, explicit arguments
894N/A * inferred: RuntimeException - should pass
894N/A */
894N/A void m9() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A new <RuntimeException> T7015430(i);
894N/A }
894N/A
894N/A /**
894N/A * Constructor invocation, unchecked, inferred arguments
894N/A * inferred: Exception - should fail
894N/A */
894N/A void m10() {
894N/A Iterable i = java.util.Collections.EMPTY_LIST;
894N/A new T7015430(i);
894N/A }
894N/A
894N/A /**
894N/A * Constructor invocation, no unchecked, inferred arguments (diamond)
894N/A * inferred: RuntimeException - should pass
894N/A */
894N/A void m11() {
894N/A Foo<RuntimeException> o = new Foo<>();
894N/A }
894N/A
894N/A /**
894N/A * Constructor invocation, no unchecked, inferred arguments (diamond)
894N/A * inferred: Exception - should fail
894N/A */
894N/A void m12() {
894N/A new Foo<>();
894N/A }
894N/A}