Do not box primitives in a single-entry string template expression

This commit is contained in:
Mikhail Zarechenskiy
2018-07-20 00:04:00 +03:00
parent 045e3f53b0
commit 9aa4247065
3 changed files with 15 additions and 1 deletions
@@ -808,7 +808,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
StringTemplateEntry entry = entries.get(0);
if (entry instanceof StringTemplateEntry.Expression) {
KtExpression expr = ((StringTemplateEntry.Expression) entry).expression;
return genToString(gen(expr), type);
return genToString(gen(expr), expressionType(expr));
}
else {
return StackValue.constant(((StringTemplateEntry.Constant) entry).value, type);
@@ -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 {
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")