File: TypeInvalid.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (60 lines) | stat: -rw-r--r-- 2,250 bytes parent folder | download | duplicates (3)
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
// Test case for Issue 292:
// https://github.com/typetools/checker-framework/issues/292

// TODO: ensure that type validation is consistently performed for each
// possible tree.
// We should also add a jtreg version of this test to
// ensure that each error is only output once and in the right place.

import org.checkerframework.checker.tainting.qual.Tainted;
import org.checkerframework.checker.tainting.qual.Untainted;

abstract class TypeInvalid {
    // :: error: (type.invalid.conflicting.annos)
    static @Untainted @Tainted class Inner {}
    // Duplication forbidden
    // :: error: (type.invalid.conflicting.annos)
    void bad(@Tainted @Untainted TypeInvalid c) {
        // :: error: (type.invalid.conflicting.annos)
        Object o = new @Tainted @Untainted Object();
        // :: error: (type.invalid.conflicting.annos)
        o = new @Tainted @Untainted Object();
        // :: error: (type.invalid.conflicting.annos)
        o = o.equals(new @Tainted @Untainted Object());
        // :: error: (type.invalid.conflicting.annos)
        o = (Object) new @Tainted @Untainted Object();
        // :: error: (type.invalid.conflicting.annos)
        o = (@Tainted @Untainted TypeInvalid) o;
        // :: error: (type.invalid.conflicting.annos)
        o = (new @Tainted @Untainted Object()) instanceof Object;
        // :: error: (type.invalid.conflicting.annos)
        o = o instanceof @Tainted @Untainted TypeInvalid;
    }

    // :: error: (type.invalid.conflicting.annos)
    @Tainted @Untainted Object bar() {
        return null;
    }

    // :: error: (type.invalid.conflicting.annos)
    abstract @Tainted @Untainted Object absbar();

    void voidmethod() {}

    TypeInvalid() {}

    // :: error: (type.invalid.conflicting.annos)
    @Tainted @Untainted TypeInvalid(int p) {}

    // :: error: (type.invalid.conflicting.annos)
    void recv(@Tainted @Untainted TypeInvalid this) {}

    // :: error: (type.invalid.conflicting.annos)
    @Tainted @Untainted Object field;

    // TODO: Note the error marker positions for the errors on fields
    // and method return types. Maybe these should be improved.

    // :: error: (type.invalid.conflicting.annos)
    void athro() throws @Tainted @Untainted Exception {}
}