diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index e84471c58bd..cf9583d9cd5 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1001,6 +1001,12 @@ public class ExpressionCodegen extends JetVisitor { gen(indices.get(0), Type.INT_TYPE); } + @Override + public void visitThrowExpression(JetThrowExpression expression) { + gen(expression.getThrownExpression(), JetTypeMapper.TYPE_OBJECT); + v.athrow(); + } + private static class CompilationException extends RuntimeException { } } diff --git a/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java b/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java index 3efc7523ddc..ad0812214a2 100644 --- a/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java @@ -85,4 +85,18 @@ public class ControlStructuresTest extends CodegenTestCase { String[] args = new String[] { "IntelliJ", " ", "IDEA" }; assertEquals("IntelliJ IDEA", main.invoke(null, new Object[] { args })); } + + public void testThrowCheckedException() throws Exception { + loadText("fun foo() { throw new Exception(); }"); + final Method main = generateFunction(); + boolean caught = false; + try { + main.invoke(null); + } catch (InvocationTargetException e) { + if (e.getTargetException().getClass() == Exception.class) { + caught = true; + } + } + assertTrue(caught); + } }