Bug 216683

Summary: [1.5][compiler] Confusion when homnymous types in local and enclosing scope
Product: [Eclipse Project] JDT Reporter: Olivier Lefevre <lefevrol>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eric_jodet, Olivier_Thomann
Version: 3.4   
Target Milestone: 3.4 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Olivier Lefevre CLA 2008-01-26 17:53:12 EST
The following code passes javac1.6 but ecj3.4M4 puts (a slew of
warnings have been omitted):
----------
1. ERROR in Bug4.java (at line 19)
        public Key<Foo, Bar> flip() { return F2B.create(); }
                                             ^^^
The type F2B is defined in an inherited type and an enclosing scope
----------
2. ERROR in Bug4.java (at line 26)
        public Key<Bar, Foo> flip() { return B2F.create(); }
                                             ^^^
The type B2F is defined in an inherited type and an enclosing scope
----------
2 problems (2 errors)
====================================================================
public class Bug4<X, Y> {

    public static interface Foo { }

    public static interface Bar { }

    private static class B2F extends Bug4<Bar, Foo> { }

    private static class F2B extends Bug4<Foo, Bar> { }

    public static abstract class Key<X, Y> {

        public abstract Key<Y, X> flip();

        private static class B2F extends Key<Bar, Foo> {

            private static B2F create() { return new B2F(); }
            
            public Key<Foo, Bar> flip() { return F2B.create(); }
        }

        private static class F2B extends Key<Foo, Bar> {
 
            private static F2B create() { return new F2B(); }

            public Key<Bar, Foo> flip() { return B2F.create(); }
        }
    }
}
Comment 1 Philipe Mulet CLA 2008-01-30 17:49:23 EST
Added InnerEmulationTest#test151.

Problem located in visibility check which should ignore non visible match post 1.4 .
Comment 2 Philipe Mulet CLA 2008-01-30 17:49:43 EST
Created attachment 88343 [details]
Proposed patch
Comment 3 Philipe Mulet CLA 2008-01-30 17:50:44 EST
Note that if compliance == 1.3, then the collision between inherited and enclosing still needs to be reported.
Comment 4 Philipe Mulet CLA 2008-01-31 03:09:44 EST
Also added InnerEmulationTest#test152
Comment 5 Philipe Mulet CLA 2008-01-31 06:04:47 EST
Released for 3.4M5.
Fixed
Comment 6 Eric Jodet CLA 2008-02-04 06:39:17 EST
Verified for 3.4M5 using build I20080204-0010
Comment 7 Philipe Mulet CLA 2008-02-28 07:36:33 EST
Released fix in 3.3.x maintenance branch (post 3.3.2)