diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/StatementRenderer.java b/core/src/main/java/org/teavm/backend/javascript/rendering/StatementRenderer.java index f34978a08..62f23432f 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/StatementRenderer.java +++ b/core/src/main/java/org/teavm/backend/javascript/rendering/StatementRenderer.java @@ -1479,7 +1479,7 @@ public class StatementRenderer implements ExprVisitor, StatementVisitor { } } else { writer.append("$rt_createMultiArray("); - context.typeToClsString(writer, expr.getType()); + context.typeToClsString(writer, type); writer.append(",").ws(); } writer.append("["); diff --git a/tests/src/test/java/org/teavm/vm/VMTest.java b/tests/src/test/java/org/teavm/vm/VMTest.java index c1b86ed63..455ac39c7 100644 --- a/tests/src/test/java/org/teavm/vm/VMTest.java +++ b/tests/src/test/java/org/teavm/vm/VMTest.java @@ -579,4 +579,16 @@ public class VMTest { array.wait(1); } } + + @Test + public void castMultiArray() { + Object o = new String[0][0]; + assertEquals(0, ((String[][]) o).length); + o = new String[0][]; + assertEquals(0, ((String[][]) o).length); + o = new int[0][0]; + assertEquals(0, ((int[][]) o).length); + o = new int[0][]; + assertEquals(0, ((int[][]) o).length); + } } \ No newline at end of file