Community
Participate
Working Groups
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.
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