diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index bf8a9d3bf76..b8cea418627 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -875,7 +875,10 @@ public class ExpressionCodegen extends KtVisitor impleme constantValue.append(String.valueOf(compileTimeConstant.getValue())); } else { - result.add(new StringTemplateEntry.Constant(constantValue.toString())); + String accumulatedConstantValue = constantValue.toString(); + if (accumulatedConstantValue.length() > 0) { + result.add(new StringTemplateEntry.Constant(accumulatedConstantValue)); + } constantValue.setLength(0); result.add(new StringTemplateEntry.Expression(entryExpression)); diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/doNotAppendEmptyString.kt b/compiler/testData/codegen/bytecodeText/stringOperations/doNotAppendEmptyString.kt new file mode 100644 index 00000000000..2f847ea23fd --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/stringOperations/doNotAppendEmptyString.kt @@ -0,0 +1,3 @@ +fun test(foo: Int) = "${foo}bar" + +// 0 LDC "" \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index ec0c4be9e24..e4e3e8d1961 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -2557,6 +2557,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/concat.kt"); } + @TestMetadata("doNotAppendEmptyString.kt") + public void testDoNotAppendEmptyString() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/doNotAppendEmptyString.kt"); + doTest(fileName); + } + @TestMetadata("interpolation.kt") public void testInterpolation() throws Exception { runTest("compiler/testData/codegen/bytecodeText/stringOperations/interpolation.kt");