File: T7015430.java

package info (click to toggle)
libnb-javaparser-java 9%2B2018-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 65,172 kB
  • sloc: java: 440,096; xml: 6,359; sh: 865; makefile: 314
file content (132 lines) | stat: -rw-r--r-- 3,366 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
 * @test /nodynamiccopyright/
 * @bug 7015430
 *
 * @summary  Incorrect thrown type determined for unchecked invocations
 * @author Daniel Smith
 * @compile/fail/ref=T7015430_1.out -source 7 -Xlint:-options,unchecked -XDrawDiagnostics T7015430.java
 * @compile/fail/ref=T7015430_2.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
 *
 */

class T7015430 {
    static <E extends Exception> Iterable<E> empty(Iterable<E> arg) throws E {
        return null;
    }

    <E extends Exception> T7015430(Iterable<E> arg) throws E { }

    static <E extends Exception> Iterable<E> empty2(Iterable x) throws E {
        return null;
    }

    static class Foo<X extends Exception> {
        Foo() throws X {}
    }

    /**
    * Method invocation, no unchecked
    * inferred: RuntimeException - should pass
    */
    void m1() {
        Iterable<RuntimeException> i = java.util.Collections.emptyList();
        empty(i);
    }

    /**
    * Method invocation, unchecked, inferred arguments
    * inferred: Exception - should fail
    */
    void m2() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        empty(i);
    }

    /**
    * Method invocation, unchecked, explicit arguments
    * inferred: RuntimeException - should pass
    */
    void m3() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        T7015430.<RuntimeException>empty(i);
    }

    /**
    * Constructor invocation, no unchecked
    * inferred: RuntimeException - should pass
    */
    void m4() {
        Iterable<RuntimeException> i = java.util.Collections.emptyList();
        new T7015430(i);
    }

    /**
    * Constructor invocation, unchecked, inferred arguments
    * inferred: Exception - should fail
    */
    void m5() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        new T7015430(i);
    }

    /**
    * Constructor invocation, unchecked, explicit arguments
    * inferred: RuntimeException - should pass
    */
    void m6() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        new <RuntimeException>T7015430(i);
    }

    /**
    * Method invocation, no unchecked, inferred arguments
    * inferred: RuntimeException - should pass
    */
    void m7() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        Iterable<RuntimeException> e = empty2(i);
    }

    /**
    * Method invocation, no unchecked, inferred arguments
    * inferred: Exception - should fail
    */
    void m8() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        empty2(i);
    }

    /**
    * Constructor invocation, unchecked, explicit arguments
    * inferred: RuntimeException - should pass
    */
    void m9() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        new <RuntimeException> T7015430(i);
    }

    /**
    * Constructor invocation, unchecked, inferred arguments
    * inferred: Exception - should fail
    */
    void m10() {
        Iterable i = java.util.Collections.EMPTY_LIST;
        new T7015430(i);
    }

    /**
    * Constructor invocation, no unchecked, inferred arguments (diamond)
    * inferred: RuntimeException - should pass
    */
    void m11() {
        Foo<RuntimeException>  o = new Foo<>();
    }

    /**
    * Constructor invocation, no unchecked, inferred arguments (diamond)
    * inferred: Exception - should fail
    */
    void m12() {
        new Foo<>();
    }
}