KT-3652: Char is converted to Int when used inside string interpolation
#KT-3652 Fixed
This commit is contained in:
@@ -354,8 +354,8 @@ public class AsmUtil {
|
|||||||
v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;");
|
v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StackValue genToString(InstructionAdapter v, StackValue receiver) {
|
public static StackValue genToString(InstructionAdapter v, StackValue receiver, Type receiverType) {
|
||||||
Type type = stringValueOfOrStringBuilderAppendType(receiver.type);
|
Type type = stringValueOfOrStringBuilderAppendType(receiverType);
|
||||||
receiver.put(type, v);
|
receiver.put(type, v);
|
||||||
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;");
|
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;");
|
||||||
return StackValue.onStack(JAVA_STRING_TYPE);
|
return StackValue.onStack(JAVA_STRING_TYPE);
|
||||||
|
|||||||
@@ -1173,7 +1173,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
JetStringTemplateEntry[] entries = expression.getEntries();
|
JetStringTemplateEntry[] entries = expression.getEntries();
|
||||||
|
|
||||||
if (entries.length == 1 && entries[0] instanceof JetStringTemplateEntryWithExpression) {
|
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) {
|
for (JetStringTemplateEntry entry : entries) {
|
||||||
|
|||||||
@@ -40,6 +40,6 @@ public class ToString implements IntrinsicMethod {
|
|||||||
StackValue receiver,
|
StackValue receiver,
|
||||||
@NotNull GenerationState state
|
@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"
|
||||||
|
}
|
||||||
+7
-2
@@ -1546,8 +1546,8 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest("compiler/testData/codegen/box/defaultArguments/constructor/kt2852.kt");
|
doTest("compiler/testData/codegen/box/defaultArguments/constructor/kt2852.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/defaultArguments/function")
|
@TestMetadata("compiler/testData/codegen/box/defaultArguments/function")
|
||||||
public static class Function extends AbstractBlackBoxCodegenTest {
|
public static class Function extends AbstractBlackBoxCodegenTest {
|
||||||
public void testAllFilesPresentInFunction() throws Exception {
|
public void testAllFilesPresentInFunction() throws Exception {
|
||||||
@@ -3686,6 +3686,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest("compiler/testData/codegen/box/strings/ea35743.kt");
|
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")
|
@TestMetadata("kt881.kt")
|
||||||
public void testKt881() throws Exception {
|
public void testKt881() throws Exception {
|
||||||
doTest("compiler/testData/codegen/box/strings/kt881.kt");
|
doTest("compiler/testData/codegen/box/strings/kt881.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user