Skip empty string entries when generating string template expression
#KT-19738 Fixed Target versions 1.2.50
This commit is contained in:
@@ -875,7 +875,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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));
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(foo: Int) = "${foo}bar"
|
||||
|
||||
// 0 LDC ""
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user