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

Bug 365407

Summary: [xbase] Validate order of types in switches, instanceof cascades and try-catch
Product: [Modeling] TMF Reporter: Sebastian Zarnekow <sebastian.zarnekow>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: anton, sven.efftinge
Version: 2.4.3   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard: v2.5.1

Description Sebastian Zarnekow CLA 2011-12-02 05:51:43 EST
The following code snippets will yield dead code:

if (a instanceof CharSequence) {
} else if (a instanceof String) {
}

switch(a) {
  CharSequence: a
  String: a
}

try {
} catch(Exception e) {
} catch(IOException e) {
}
Comment 1 Anton Kosyakov CLA 2014-01-09 08:14:12 EST
We should check that case with constant expression are duplicated.

For example:
val y = 2
val z = 2
switch x : 1 {
  case 1 + y: true
  case 1 + z: false
}

Here cases are duplicated and it will cause errors in generated java code.
Comment 2 Anton Kosyakov CLA 2014-01-10 09:34:49 EST
Pushed to review: https://git.eclipse.org/r/20495 - added duplicate cases check
Comment 3 Anton Kosyakov CLA 2014-01-17 14:37:39 EST
pushed to review: https://git.eclipse.org/r/20767
Comment 4 Eclipse Webmaster CLA 2017-10-31 11:05:27 EDT
Requested via bug 522520.

-M.
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:16:47 EDT
Requested via bug 522520.

-M.