summaryrefslogtreecommitdiffstats
path: root/tests/pureJava/InvalidNewQualifier15CE.java
blob: 7b627e698642e33c1afb89dda637475bd208785e (plain)
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
/** @testcase PUREJAVA nested interface does not require new qualifier */
public class InvalidNewQualifier15CE {
    interface I {}
    void test() {
        // error
//         this.new I(){};  // CE 7 new qualification unneeded
//         new Outer().new Outer.I(){}; // CE 8 new qualification bad
//         new OuterInterface(){}.new OuterInterface.I(){}; // CE 9 new qualification bad
//         new OuterOuter.Inner(){}.new OuterOuter.Inner.I(){}; // CE 10 new qualification bad
        Outer o = new Outer();
        OuterInterface oi = new OuterInterface(){};
        OuterOuter.Inner ooi = new OuterOuter.Inner(){}; 
//         o.new Outer.I(){}; // CE 14 new qualification bad
         oi.new OuterInterface.I(){}; // CE 15 new qualification bad
//         ooi.new OuterOuter.Inner.I(){}; // CE 16 new qualification bad

        // ok
        new I(){};  
        new Outer.I(){}; 
        new OuterInterface.I(){};
        new OuterOuter.Inner.I(){};
    }
}

class Outer {
    interface I {}
}
interface OuterInterface {
    interface I {}
}
class OuterOuter {
    interface Inner {
        interface I {}
    }
}