From c63ac3e30a21cdbb34fb808edb7e90a2327eb390 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Sat, 4 Apr 2015 14:22:38 +0300 Subject: [PATCH] Test for KT-7222 Redundant boxing on toString call #KT-7222 Fixed --- .../stringOperations/primitiveToString.kt | 14 ++++++++++++++ .../kotlin/codegen/BytecodeTextTestGenerated.java | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt b/compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt new file mode 100644 index 00000000000..b55d752919c --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt @@ -0,0 +1,14 @@ +fun main() { + false.toString() + 1.toByte().toString() + 1.toShort().toString() + 1.toString() + 1L.toString() + 1.0F.toString() + 1.0.toString() + 'c'.toString() +} + +/*Check that all "valueOf" are String ones and there is no boxing*/ +// 8 valueOf +// 8 INVOKESTATIC java/lang/String.valueOf diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 72a4fda9089..915c65f2493 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -687,6 +687,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/plusAssign.kt"); doTest(fileName); } + + @TestMetadata("primitiveToString.kt") + public void testPrimitiveToString() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/codegen/bytecodeText/when")