Bug 83228 - [1.5] enum declaration and reference have different bindings inside generic class
Summary: [1.5] enum declaration and reference have different bindings inside generic c...
Status: RESOLVED DUPLICATE of bug 83064
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 83229
  Show dependency tree
 
Reported: 2005-01-19 14:02 EST by Markus Keller CLA
Modified: 2006-04-12 15:09 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-01-19 14:02:19 EST
I20050118-1015

The bindings for "Numbers" after "enum" and for "Numbers" before getSquare() are
not identical nor isEqualTo(..) each other, but their getKey()s are the same.
IMO, the bindings should be identical.

class Generic<E> {
    enum Numbers {
        ONE {
            Numbers getSquare() {
                return ONE;
            }
        };
        abstract Numbers getSquare();
    }
}
Comment 1 Olivier Thomann CLA 2005-01-19 16:19:50 EST
I will investigate.
Comment 2 Olivier Thomann CLA 2005-01-19 17:49:46 EST
The second Numbers is seen as a ParameterizedTypeBinding that contains a
MemberTypeBinding that is the right one.
I will investigate why we get a parameterized type binding.
Comment 3 Olivier Thomann CLA 2005-01-26 14:55:57 EST
Philippe, could you please tell me why the second Numbers name is a
ParameterizedTypeBinding?
Thanks.
Comment 4 Philipe Mulet CLA 2005-02-08 10:43:59 EST
I agree it is cumbersome. Currently, the reference to Numbers within Numbers is
the source type binding (i.e. MemberTypeBinding with SourceTypeBinding:
Generic<E> as its enclosing type).

When accessed from the outside of Numbers definition, it is seen differently.
Though it does not quite make sense IMO, since it isn't generic.
Comment 5 Volker Renneberg CLA 2005-04-06 03:25:40 EDT
To my mind, this bug also shows up in the following case (two java-classes)
***TakeEnumPar.java (first class):
public interface TakeEnumPar<E extends Enum<E>> {
}
***TestTakeEnum.java (second class):
public class TestTakeEnum<A> {
    public enum MyEnum {
        A, B, C
    };

    private final static TakeEnumPar<MyEnum> x = new TakeEnumPar<MyEnum>() {
    };
}
****

Try to compile the two files with eclipse and with JDK. With ecplise an error 
will be shown in the second class when declaring the static variable x. MyEnum 
is said to be no substitution for the generic Enum-type parameter. If you 
remove the generic type variable from the second class, however, everything 
works fine. To my mind it seems, that static elements like the enum are 
qualified by the generic type variable of the second class, although they are 
static.

ciao
Volker
Comment 6 Philipe Mulet CLA 2005-04-19 08:03:10 EDT

*** This bug has been marked as a duplicate of 83064 ***
Comment 7 Olivier Thomann CLA 2006-04-12 15:09:29 EDT
Bug 83064 is fixed, but the regression test for this one is still failing.