don't crash when appending an array to StringBuilder
This commit is contained in:
@@ -1316,7 +1316,7 @@ public class ExpressionCodegen extends JetVisitor {
|
||||
}
|
||||
Type exprType = expressionType(expr);
|
||||
gen(expr, exprType);
|
||||
invokeAppendMethod(exprType);
|
||||
invokeAppendMethod(exprType.getSort() == Type.ARRAY ? JetTypeMapper.TYPE_OBJECT : exprType);
|
||||
}
|
||||
|
||||
public void invokeAppendMethod(Type exprType) {
|
||||
|
||||
@@ -481,4 +481,12 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
final Method main = generateFunction();
|
||||
assertEquals(false, ((Boolean) main.invoke(null, true)).booleanValue());
|
||||
}
|
||||
|
||||
public void testAppendArrayToString() throws Exception {
|
||||
loadText("fun foo(a: String, b: Array<String>) = a + b");
|
||||
final Method main = generateFunction();
|
||||
final String[] args = new String[] { "foo", "bar" };
|
||||
//noinspection ImplicitArrayToString
|
||||
assertEquals("s" + args.toString(), main.invoke(null, "s", args));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user