Improve string concatentation & string templates code generation

Reuse StringBuilder instances for nested subexpressions.
(NB StringBuilder instance for string template with a string
concatenation inside an expression entry, such as `"${"a" + "b"}"`,
will not be reused, although that doesn't seem to be a real-life issue).

 #KT-18558 Fixed Target versions 1.1.4
 #KT-13682 Fixed Target versions 1.1.4

Join adjacent strings literals, escaped strings, and constant values
(in a language version that supports const val inlining).
Use StringBuilder#append(char) for single-character constants
(e.g., " " in "$a $b").

 #KT-17280 Fixed Target versions 1.1.4
 #KT-15235 Fixed Target versions 1.1.4
This commit is contained in:
Dmitry Petrov
2017-06-20 17:08:39 +03:00
parent ae71833a12
commit a84c2a6f31
17 changed files with 313 additions and 56 deletions
@@ -4796,6 +4796,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
@TestMetadata("kt9532.kt")
public void testKt9532() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constants/kt9532.kt");
doTest(fileName);
}
@TestMetadata("kt9532_lv10.kt")
public void testKt9532_lv10() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constants/kt9532_lv10.kt");
try {
doTest(fileName);
}
@@ -21512,6 +21518,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/strings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("constInStringTemplate.kt")
public void testConstInStringTemplate() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/constInStringTemplate.kt");
doTest(fileName);
}
@TestMetadata("ea35743.kt")
public void testEa35743() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/ea35743.kt");
@@ -21590,6 +21602,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("nestedConcat.kt")
public void testNestedConcat() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/nestedConcat.kt");
doTest(fileName);
}
@TestMetadata("rawStrings.kt")
public void testRawStrings() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/rawStrings.kt");