Summary: | Switching on strings in 1.6- modes produces misleading message | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Srikanth Sankaran <srikanth_sankaran> | ||||
Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P5 | CC: | amj87.iitr, stephan.herrmann | ||||
Version: | 3.7 | ||||||
Target Milestone: | 3.8 M2 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Srikanth Sankaran
2011-07-19 04:25:26 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". Created attachment 201099 [details]
proposed fix v1.0 + updated tests
Corrected all the switch related errors, replacing "enum constants" with "enum variables"
Released in HEAD for 3.8M2 Verified for 3.8M2 using build I20110911-2000. |