Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365407 - [xbase] Validate order of types in switches, instanceof cascades and try-catch
Summary: [xbase] Validate order of types in switches, instanceof cascades and try-catch
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.4.3   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: v2.5.1
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-02 05:51 EST by Sebastian Zarnekow CLA
Modified: 2017-10-31 11:16 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.