test/tools/javac/generics/6711619/T6711619a.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/generics/6711619/T6711619a.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,51 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 6711619
     1.7 + *
     1.8 + * @summary javac doesn't allow access to protected members in intersection types
     1.9 + * @author Maurizio Cimadamore
    1.10 + *
    1.11 + * @compile/fail/ref=T6711619a.out -XDrawDiagnostics T6711619a.java
    1.12 + */
    1.13 +class T6711619a {
    1.14 +
    1.15 +    static class A {
    1.16 +        private void a() {}
    1.17 +        private A a;
    1.18 +    }
    1.19 +    static class B extends A {
    1.20 +        private B b() {}
    1.21 +        private B b;
    1.22 +    }
    1.23 +    static interface I{
    1.24 +        void i();
    1.25 +    }
    1.26 +    static interface I1{
    1.27 +        void i1();
    1.28 +    }
    1.29 +    static class E extends B implements I, I1{
    1.30 +        public void i() {}
    1.31 +        public void i1() {}
    1.32 +    }
    1.33 +    static class C<W extends B & I1, T extends W>{
    1.34 +        T t;
    1.35 +        W w;
    1.36 +        C(W w, T t) {
    1.37 +            this.w = w;
    1.38 +            this.t = t;
    1.39 +        }
    1.40 +    }
    1.41 +
    1.42 +    static void testMemberMethods(C<? extends A, ? extends I> arg) {
    1.43 +        arg.t.a();
    1.44 +        arg.t.b();
    1.45 +    }
    1.46 +
    1.47 +    static void testMemberFields(C<? extends A, ? extends I> arg) {
    1.48 +        A ta; B tb;
    1.49 +        ta = arg.t.a;
    1.50 +        tb = arg.t.b;
    1.51 +        ta = arg.w.a;
    1.52 +        tb = arg.w.b;
    1.53 +    }
    1.54 +}

mercurial