Bug 211718 - [1.5][compiler] compiler error with nested enum in class using generics
Summary: [1.5][compiler] compiler error with nested enum in class using generics
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.3.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-03 00:51 EST by Martin Stenhoff CLA
Modified: 2008-02-04 12:08 EST (History)
3 users (show)

See Also:
philippe_mulet: pmc_approved+


Attachments
Java class triggering eclipse compiler bug (1.04 KB, text/x-java)
2007-12-03 00:51 EST, Martin Stenhoff CLA
no flags Details
Proposed patch (1.62 KB, patch)
2007-12-12 09:58 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 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