Bug 216683 - [1.5][compiler] Confusion when homnymous types in local and enclosing scope
Summary: [1.5][compiler] Confusion when homnymous types in local and enclosing scope
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-26 17:53 EST by Olivier Lefevre CLA
Modified: 2008-02-28 07:36 EST (History)
2 users (show)

See Also:


Attachments
Proposed patch (8.06 KB, patch)
2008-01-30 17:49 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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)