File: CompoundStringAssignment.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (43 lines) | stat: -rw-r--r-- 1,112 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
import testchecker.quals.*;

class CompoundStringAssignment {
    @H1S1 @H2S1 String getSib1() {
        return null;
    }

    void test1() {
        String local = null;
        // There was a bug in data flow where
        // the type of local was @H1Bot @H2Bot after this
        // StringConcatenateAssignmentNode,
        // but only if the RHS was a method call.
        local += getSib1();

        // :: error: (assignment.type.incompatible)
        @H1Bot @H2Bot String isBot = local;
        @H1S1 @H2S1 String isSib1 = local;
    }

    @H1Top @H2Top String top;

    void test2() {
        String local2 = top;
        local2 += getSib1();

        // :: error: (assignment.type.incompatible)
        @H1Bot @H2Bot String isBot2 = local2;
        // :: error: (assignment.type.incompatible)
        @H1S1 @H2S1 String isSib12 = local2;
    }

    @H1S1 @H2S1 String sib1;

    void test3() {
        String local3 = null;
        local3 += sib1;

        // :: error: (assignment.type.incompatible)
        @H1Bot @H2Bot String isBot3 = local3;
        @H1S1 @H2S1 String isSib13 = local3;
    }
}