Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343475

Summary: [1.7] Compiler warning for invalid type inside switch needs to be improved
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: deepakazad, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
proposed fix none

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"