Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343475 - [1.7] Compiler warning for invalid type inside switch needs to be improved
Summary: [1.7] Compiler warning for invalid type inside switch needs to be improved
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.7.1   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 02:01 EDT by Ayushman Jain CLA
Modified: 2011-08-05 02:54 EDT (History)
2 users (show)

See Also:


Attachments
proposed fix (27.79 KB, patch)
2011-04-21 02:08 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 Ayushman Jain CLA 2011-04-21 02:01:25 EDT
BETA_JAVA7

Currently for an invalid type inside a switch statement, we warn
Cannot switch on a value of type {0}. Only convertible int values or enum constants are permitted.

From 1.7 onwards however, strings are permitted too, so the warning for 1.7 should reflect that.

public class Try {
  void f(Object a) {
     final String xyzz = "";
     switch (a){    // error here
         case xyzz: break;
     }
  }
}
Comment 1 Ayushman Jain CLA 2011-04-21 02:08:26 EDT
Created attachment 193778 [details]
proposed fix

Fixes the error message for 1.7 and above
Comment 2 Ayushman Jain CLA 2011-04-21 02:11:01 EDT
Released in BETA_JAVA7 branch.
Comment 3 Ayushman Jain CLA 2011-04-21 02:12:10 EDT
(In reply to comment #0)
> Cannot switch on a value of type {0}. Only convertible int values or enum
> constants are permitted.

New error is "Cannot switch on a value of type {0}. Only convertible int values, strings or enum constants are permitted"
Comment 4 Srikanth Sankaran CLA 2011-06-28 05:05:52 EDT
Verified using "Eclipse Java Development Tools Patch for Java 7 Support (BETA)	1.0.0.v20110623-0900	org.eclipse.jdt.patch.feature.group	Eclipse.org"