test/tools/javac/generics/7015430/T7015430.java

Mon, 21 Jan 2013 20:13:56 +0000

author
mcimadamore
date
Mon, 21 Jan 2013 20:13:56 +0000
changeset 1510
7873d37f5b37
parent 895
9286a5d1fae3
child 1896
44e27378f523
permissions
-rw-r--r--

8005244: Implement overload resolution as per latest spec EDR
Summary: Add support for stuck expressions and provisional applicability
Reviewed-by: jjg

mcimadamore@895 1 /*
mcimadamore@895 2 * @test /nodynamiccopyright/
mcimadamore@895 3 * @bug 7015430
mcimadamore@895 4 *
mcimadamore@895 5 * @summary Incorrect thrown type determined for unchecked invocations
mcimadamore@895 6 * @author Daniel Smith
mcimadamore@895 7 * @compile/fail/ref=T7015430.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
mcimadamore@895 8 *
mcimadamore@895 9 */
mcimadamore@895 10
mcimadamore@895 11 class T7015430 {
mcimadamore@895 12 static <E extends Exception> Iterable<E> empty(Iterable<E> arg) throws E {
mcimadamore@895 13 return null;
mcimadamore@895 14 }
mcimadamore@895 15
mcimadamore@895 16 <E extends Exception> T7015430(Iterable<E> arg) throws E { }
mcimadamore@895 17
mcimadamore@895 18 static <E extends Exception> Iterable<E> empty2(Iterable x) throws E {
mcimadamore@895 19 return null;
mcimadamore@895 20 }
mcimadamore@895 21
mcimadamore@895 22 static class Foo<X extends Exception> {
mcimadamore@895 23 Foo() throws X {}
mcimadamore@895 24 }
mcimadamore@895 25
mcimadamore@895 26 /**
mcimadamore@895 27 * Method invocation, no unchecked
mcimadamore@895 28 * inferred: RuntimeException - should pass
mcimadamore@895 29 */
mcimadamore@895 30 void m1() {
mcimadamore@895 31 Iterable<RuntimeException> i = java.util.Collections.emptyList();
mcimadamore@895 32 empty(i);
mcimadamore@895 33 }
mcimadamore@895 34
mcimadamore@895 35 /**
mcimadamore@895 36 * Method invocation, unchecked, inferred arguments
mcimadamore@895 37 * inferred: Exception - should fail
mcimadamore@895 38 */
mcimadamore@895 39 void m2() {
mcimadamore@895 40 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 41 empty(i);
mcimadamore@895 42 }
mcimadamore@895 43
mcimadamore@895 44 /**
mcimadamore@895 45 * Method invocation, unchecked, explicit arguments
mcimadamore@895 46 * inferred: RuntimeException - should pass
mcimadamore@895 47 */
mcimadamore@895 48 void m3() {
mcimadamore@895 49 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 50 T7015430.<RuntimeException>empty(i);
mcimadamore@895 51 }
mcimadamore@895 52
mcimadamore@895 53 /**
mcimadamore@895 54 * Constructor invocation, no unchecked
mcimadamore@895 55 * inferred: RuntimeException - should pass
mcimadamore@895 56 */
mcimadamore@895 57 void m4() {
mcimadamore@895 58 Iterable<RuntimeException> i = java.util.Collections.emptyList();
mcimadamore@895 59 new T7015430(i);
mcimadamore@895 60 }
mcimadamore@895 61
mcimadamore@895 62 /**
mcimadamore@895 63 * Constructor invocation, unchecked, inferred arguments
mcimadamore@895 64 * inferred: Exception - should fail
mcimadamore@895 65 */
mcimadamore@895 66 void m5() {
mcimadamore@895 67 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 68 new T7015430(i);
mcimadamore@895 69 }
mcimadamore@895 70
mcimadamore@895 71 /**
mcimadamore@895 72 * Constructor invocation, unchecked, explicit arguments
mcimadamore@895 73 * inferred: RuntimeException - should pass
mcimadamore@895 74 */
mcimadamore@895 75 void m6() {
mcimadamore@895 76 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 77 new <RuntimeException>T7015430(i);
mcimadamore@895 78 }
mcimadamore@895 79
mcimadamore@895 80 /**
mcimadamore@895 81 * Method invocation, no unchecked, inferred arguments
mcimadamore@895 82 * inferred: RuntimeException - should pass
mcimadamore@895 83 */
mcimadamore@895 84 void m7() {
mcimadamore@895 85 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 86 Iterable<RuntimeException> e = empty2(i);
mcimadamore@895 87 }
mcimadamore@895 88
mcimadamore@895 89 /**
mcimadamore@895 90 * Method invocation, no unchecked, inferred arguments
mcimadamore@895 91 * inferred: Exception - should fail
mcimadamore@895 92 */
mcimadamore@895 93 void m8() {
mcimadamore@895 94 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 95 empty2(i);
mcimadamore@895 96 }
mcimadamore@895 97
mcimadamore@895 98 /**
mcimadamore@895 99 * Constructor invocation, unchecked, explicit arguments
mcimadamore@895 100 * inferred: RuntimeException - should pass
mcimadamore@895 101 */
mcimadamore@895 102 void m9() {
mcimadamore@895 103 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 104 new <RuntimeException> T7015430(i);
mcimadamore@895 105 }
mcimadamore@895 106
mcimadamore@895 107 /**
mcimadamore@895 108 * Constructor invocation, unchecked, inferred arguments
mcimadamore@895 109 * inferred: Exception - should fail
mcimadamore@895 110 */
mcimadamore@895 111 void m10() {
mcimadamore@895 112 Iterable i = java.util.Collections.EMPTY_LIST;
mcimadamore@895 113 new T7015430(i);
mcimadamore@895 114 }
mcimadamore@895 115
mcimadamore@895 116 /**
mcimadamore@895 117 * Constructor invocation, no unchecked, inferred arguments (diamond)
mcimadamore@895 118 * inferred: RuntimeException - should pass
mcimadamore@895 119 */
mcimadamore@895 120 void m11() {
mcimadamore@895 121 Foo<RuntimeException> o = new Foo<>();
mcimadamore@895 122 }
mcimadamore@895 123
mcimadamore@895 124 /**
mcimadamore@895 125 * Constructor invocation, no unchecked, inferred arguments (diamond)
mcimadamore@895 126 * inferred: Exception - should fail
mcimadamore@895 127 */
mcimadamore@895 128 void m12() {
mcimadamore@895 129 new Foo<>();
mcimadamore@895 130 }
mcimadamore@895 131 }

mercurial