Do not box primitives in a single-entry string template expression
This commit is contained in:
@@ -808,7 +808,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
StringTemplateEntry entry = entries.get(0);
|
StringTemplateEntry entry = entries.get(0);
|
||||||
if (entry instanceof StringTemplateEntry.Expression) {
|
if (entry instanceof StringTemplateEntry.Expression) {
|
||||||
KtExpression expr = ((StringTemplateEntry.Expression) entry).expression;
|
KtExpression expr = ((StringTemplateEntry.Expression) entry).expression;
|
||||||
return genToString(gen(expr), type);
|
return genToString(gen(expr), expressionType(expr));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return StackValue.constant(((StringTemplateEntry.Constant) entry).value, type);
|
return StackValue.constant(((StringTemplateEntry.Constant) entry).value, type);
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fun test(b: Byte, s: Short, i: Int, l: Long) {
|
||||||
|
"$b"
|
||||||
|
"$s"
|
||||||
|
"$i"
|
||||||
|
"$l"
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4 valueOf
|
||||||
|
// 4 INVOKESTATIC java/lang/String.valueOf
|
||||||
@@ -2747,6 +2747,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
public void testPrimitiveToString() throws Exception {
|
public void testPrimitiveToString() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt");
|
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("primitivesAsStringTemplates.kt")
|
||||||
|
public void testPrimitivesAsStringTemplates() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitivesAsStringTemplates.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeText/varargs")
|
@TestMetadata("compiler/testData/codegen/bytecodeText/varargs")
|
||||||
|
|||||||
Reference in New Issue
Block a user