File: ThisSuper.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 (43 lines) | stat: -rw-r--r-- 1,311 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
// Test case for
// https://github.com/typetools/checker-framework/issues/152
import testlib.flowexpression.qual.FlowExp;

// @skip-test
public class ThisSuper {
    static class SuperClass {
        protected final Object field = new Object();

        private @FlowExp("field") Object superField;
    }

    static class SubClass extends SuperClass {
        /* Hides SuperClass.field */
        private final Object field = new Object();

        private @FlowExp("field") Object subField;

        void method() {
            // super.superField : @FlowExp("super.field")
            // this.subField : @FlowExp("this.field")
            // :: error: (assignment.type.incompatible)
            this.subField = super.superField;
            // :: error: (assignment.type.incompatible)
            super.superField = this.subField;

            @FlowExp("super.field") Object o1 = super.superField;
            @FlowExp("this.field") Object o2 = this.subField;
        }
    }

    class OuterClass {
        private final Object lock = new Object();

        @FlowExp("this.lock") Object field;

        class InnerClass {
            private final Object lock = new Object();
            // :: error: (assignment.type.incompatible)
            @FlowExp("this.lock") Object field2 = field;
        }
    }
}