Bug 352412 - Switching on strings in 1.6- modes produces misleading message
Summary: Switching on strings in 1.6- modes produces misleading message
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: 3.8 M2   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-19 04:25 EDT by Srikanth Sankaran CLA
Modified: 2011-09-13 09:50 EDT (History)
2 users (show)

See Also:


Attachments
proposed fix v1.0 + updated tests (15.65 KB, patch)
2011-08-08 14:46 EDT, Ayushman Jain CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2011-07-19 04:25:26 EDT
BETA_JAVA7 branch.

"Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted" is the message
we issue when there is an attempt to switch on strings in source levels
1.6-.

The latter part of message is obviously incorrect, as you can switch
on a enum variable. In fact there is no reason why you would want to
switch on an enum constant.

The phrase "convertible int values" is also not particularly helpful.
Comment 1 Ayushman Jain CLA 2011-07-19 04:41:13 EDT
(In reply to comment #0)
> BETA_JAVA7 branch.
> 
> "Cannot switch on a value of type String for source level below 1.7. Only
> convertible int values or enum constants are permitted" is the message
> we issue when there is an attempt to switch on strings in source levels
> 1.6-.
> 
> The latter part of message is obviously incorrect, as you can switch
> on a enum variable. In fact there is no reason why you would want to
> switch on an enum constant.
> 
> The phrase "convertible int values" is also not particularly helpful.

Two things:
1) An identical warning is also seen for invalid switches for 1.6- where we're not switching on a string.
2) The part that says "convertible int values" sounds ok since we need to cover all the types that can be converted to an integral number, such as a char. So the following is still valid:
char c = 'a';
		switch(c) {
		case 'a':
		case 'b':
		}

Hence the bug comes down to changing "enum constants" to "enum variables".
Comment 2 Ayushman Jain CLA 2011-08-08 14:46:39 EDT
Created attachment 201099 [details]
proposed fix v1.0 + updated tests

Corrected all the switch related errors, replacing "enum constants" with "enum variables"
Comment 3 Ayushman Jain CLA 2011-08-09 10:33:15 EDT
Released in HEAD for 3.8M2
Comment 4 Stephan Herrmann CLA 2011-09-13 09:50:39 EDT
Verified for 3.8M2 using build I20110911-2000.