| Summary: | [xtend] validate that the same exception isn't caught multiple times | ||
|---|---|---|---|
| Product: | [Tools] Xtend | Reporter: | Moritz Eysholdt <moritz.eysholdt> |
| Component: | Core | Assignee: | Project Inbox <xtend-inbox> |
| Status: | RESOLVED WORKSFORME | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | christian.dietrich.opensource, sven.efftinge |
| Version: | 2.2.0 | Flags: | sven.efftinge:
juno+
|
| Target Milestone: | --- | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
The same applies of a supertype of an exception is caught before its subtype:
---
try { new File("foo").canonicalPath } catch(Exception o) { "bar" } catch(IOException o) { "bar" }
---
Our Deady code detection catches this case menawhile |
Example ---- class foo { def bar() { try { new File("foo").canonicalPath } catch(IOException o) { "bar" } catch(IOException o) { "bar" } } } ---- Compiles to ----- public class foo { public String bar() { String _xtrycatchfinallyexpression = null; try { File _file = new File("foo"); String _canonicalPath = _file.getCanonicalPath(); _xtrycatchfinallyexpression = _canonicalPath; } catch (final IOException o) { _xtrycatchfinallyexpression = "bar"; } catch (final IOException o_1) { _xtrycatchfinallyexpression = "bar"; } return _xtrycatchfinallyexpression; } } ---- The Java code doesn't compile due to the error "Unreachable catch block for IOException. It is already handled by the catch block for IOException". I'd expect to see the same validation error in Xtend.