KT-3652: Char is converted to Int when used inside string interpolation

#KT-3652 Fixed
This commit is contained in:
Mikhael Bogdanov
2013-05-27 14:38:05 +04:00
parent 40146c6341
commit e96cf045dd
5 changed files with 21 additions and 6 deletions
@@ -354,8 +354,8 @@ public class AsmUtil {
v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;");
}
public static StackValue genToString(InstructionAdapter v, StackValue receiver) {
Type type = stringValueOfOrStringBuilderAppendType(receiver.type);
public static StackValue genToString(InstructionAdapter v, StackValue receiver, Type receiverType) {
Type type = stringValueOfOrStringBuilderAppendType(receiverType);
receiver.put(type, v);
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;");
return StackValue.onStack(JAVA_STRING_TYPE);
@@ -1173,7 +1173,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetStringTemplateEntry[] entries = expression.getEntries();
if (entries.length == 1 && entries[0] instanceof JetStringTemplateEntryWithExpression) {
return genToString(v, gen(entries[0].getExpression()));
JetExpression expr = entries[0].getExpression();
return genToString(v, gen(expr), expressionType(expr));
}
for (JetStringTemplateEntry entry : entries) {
@@ -40,6 +40,6 @@ public class ToString implements IntrinsicMethod {
StackValue receiver,
@NotNull GenerationState state
) {
return genToString(v, receiver);
return genToString(v, receiver, receiver.type);
}
}
@@ -0,0 +1,9 @@
fun box(): String {
var a = 'a'
if ("${a++}x" != "ax") return "fail1"
if ("${a++}" != "b") return "fail2"
return "OK"
}
@@ -1546,8 +1546,8 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/defaultArguments/constructor/kt2852.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/box/defaultArguments/function")
public static class Function extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInFunction() throws Exception {
@@ -3686,6 +3686,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/strings/ea35743.kt");
}
@TestMetadata("kt3652.kt")
public void testKt3652() throws Exception {
doTest("compiler/testData/codegen/box/strings/kt3652.kt");
}
@TestMetadata("kt881.kt")
public void testKt881() throws Exception {
doTest("compiler/testData/codegen/box/strings/kt881.kt");