Bug 82217 - [compiler][5.0] switch on enum allows non enum constants
Summary: [compiler][5.0] switch on enum allows non enum constants
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-05 04:45 EST by Martin Aeschlimann CLA
Modified: 2005-02-15 05:27 EST (History)
0 users

See Also:


Attachments

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