Bug 82217

Summary: [compiler][5.0] switch on enum allows non enum constants
Product: [Eclipse Project] JDT Reporter: Martin Aeschlimann <martinae>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Martin Aeschlimann CLA 2005-01-05 04:45:52 EST
20050105

The compiler allows this. I guess only enum contants should be allowed.
Note that X should probably also not be visible without qualification in the
switch statement.

public enum E {
	A, B, C;
	public static final E X= null;
}

class A {
	private void foo(E e) {
		switch (e) {
			case X:
		}
	}
}
Comment 1 Philipe Mulet CLA 2005-01-06 07:39:40 EST
Wasn't checking the field was a proper enum constant; added check and new
problem for this.
Added EnumTest#test061.
Fixed in latest.
Comment 2 Jerome Lanneluc CLA 2005-02-15 05:27:24 EST
Verified in I20050214