Bug 211718

Summary: [1.5][compiler] compiler error with nested enum in class using generics
Product: [Eclipse Project] JDT Reporter: Martin Stenhoff <supersede_>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: david_audel, jerome_lanneluc, philippe_mulet
Version: 3.3.1Flags: philippe_mulet: pmc_approved+
Target Milestone: 3.3.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Java class triggering eclipse compiler bug
none
Proposed patch none

Description Martin Stenhoff CLA 2007-12-03 00:51:47 EST
Created attachment 84291 [details]
Java class triggering eclipse compiler bug

Build ID: M20071023-1652

Steps To Reproduce:
The attached java class fails to compile in eclipse with compiler error:
Type mismatch: cannot convert from EnumGenericsBug<E>.IsABug to EnumGenericsBug.IsABug


More information:
The class compiles with javac in jdk1.5.0_14,jdk1.6.0_3 and jdk-1.7_oct-2007.
Short version of class:
import java.util.Arrays;
import java.util.List;
public class EnumGenericsBug<E> {
    public static enum IsABug {
        TRUE,
        FALSE;
    }   
    public List<IsABug> getPossibleBugStates() {
        return Arrays.asList(IsABug.values());
    }
}
Comment 1 Philipe Mulet CLA 2007-12-12 09:25:18 EST
Reproduced in latest.
Comment 2 Philipe Mulet CLA 2007-12-12 09:55:11 EST
Added GenericTypeTest#test1123
Comment 3 Philipe Mulet CLA 2007-12-12 09:58:55 EST
Created attachment 85073 [details]
Proposed patch

Problem came from incorrect construction for synthetic enum method types. They were referring to the generic type, instead of referring to a parameterized form of the generic type, and thus did not convert properly from thereon.
Comment 4 Philipe Mulet CLA 2007-12-12 15:48:07 EST
Fix is simple, it could easily be backported for 3.3.2.
Comment 5 Jerome Lanneluc CLA 2007-12-13 07:38:38 EST
Perfectly legit code failed to compile. The fix is simple and there is no possible workaround. Requesting approval to backport to 3.3.2.
Comment 6 Philipe Mulet CLA 2007-12-13 07:43:38 EST
+1 for 3.3.2.
Comment 7 Philipe Mulet CLA 2007-12-18 07:52:40 EST
Released for 3.4M5.
Fixed
Comment 8 Philipe Mulet CLA 2007-12-18 09:10:34 EST
Released for 3.3.2
Comment 9 David Audel CLA 2008-01-24 05:02:59 EST
Verified for 3.3.2 using build M20080123-0800
Comment 10 Jerome Lanneluc CLA 2008-02-04 12:08:00 EST
Verified for 3.4M5 using I20080204-0010