Bug 126177

Summary: [1.5][compiler] Visibility issue with intersection type
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Philipe Mulet CLA 2006-02-02 08:45:43 EST
Build 3.2m4

Following code should be accepted:
public class X {
	static class C1 {
		void c1m1() {
			System.out.println("FISK");
		}
	}

	static interface I {
	}

	static class C2 extends C1 implements I {
	}

	static class C3 extends C1 implements I {
	}

	public <T> T m1(T t1, T t2) {
		return null;
	}

	public <T extends C1 & I> void test(C2 c2, C3 c3, T t) {
		m1(c2, c3).c1m1(); // 1
		t.c1m1(); // 2
		(t != null ? c2 : c3).c1m1(); // 3
	}

	public static void main(String... args) {
		Test t = new Test();
		t.test(new C2(), new C3(), new C2()); // 4
	}
}
Comment 1 Philipe Mulet CLA 2006-02-02 08:46:03 EST
Also see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5073060
Comment 2 Philipe Mulet CLA 2006-02-02 09:42:52 EST
Note that field and member types accesses are similarily affected.
Added GenericTypeTest#test893.

Fixed
Comment 3 Philipe Mulet CLA 2006-02-02 10:29:40 EST
Backported to 3.1.x.
Comment 4 Philipe Mulet CLA 2006-02-02 10:44:42 EST
Better testcase:
public class X {
        static class C1 {
                void c1m1() {
                        System.out.print("[c1m1]");
                }
        }
        static interface I {}
        static class C2 extends C1 implements I {}
        static class C3 extends C1 implements I {}

        public <T> T m1(T t1, T t2) {
                return t1;
        }

        public <T extends C1 & I> void test(C2 c2, C3 c3, T t) {
                m1(c2, c3).c1m1(); // 1
                t.c1m1(); // 2
                (t != null ? c2 : c3).c1m1(); // 3
        }

        public static void main(String... args) {
                X x = new X();
                x.test(new C2(), new C3(), new C2()); // 4
                System.out.println();
        }
}
Comment 5 Philipe Mulet CLA 2006-02-02 10:45:03 EST
Also added GenericTypeTest#test894
Comment 6 Jerome Lanneluc CLA 2006-02-15 07:45:59 EST
Verified for 3.2 M5 using build I20060215-0010