Add test for for kt42457 wrong behaviour. Align runtime concatenation with it

#KT-42457
This commit is contained in:
Mikhael Bogdanov
2020-10-06 08:33:03 +02:00
parent 64fb114c30
commit eb32a6ddbd
10 changed files with 75 additions and 0 deletions
@@ -30208,6 +30208,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/strings/kt3652.kt");
}
@TestMetadata("kt42457_old.kt")
public void testKt42457_old() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt42457_old.kt");
}
@TestMetadata("kt5389_stringBuilderGet.kt")
public void testKt5389_stringBuilderGet() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt");
@@ -4551,6 +4551,11 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt19037.kt");
}
@TestMetadata("kt42457_old.kt")
public void testKt42457_old() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt42457_old.kt");
}
@TestMetadata("multipleNestedConcat.kt")
public void testMultipleNestedConcat() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt");
@@ -193,6 +193,9 @@ private class JvmDynamicStringConcatenationLowering(val context: JvmBackendConte
arguments.isEmpty() ->
irString("")
arguments.size == 1 ->
lowerInlineClassArgument(arguments[0]) ?: callToString(arguments[0].unwrapImplicitNotNull())
else -> {
IrStringConcatenationImpl(
expression.startOffset,
+17
View File
@@ -0,0 +1,17 @@
// TARGET_BACKEND: JVM
// FILE: JavaClass.java
public class JavaClass {
public String toString() {
return null;
}
}
// FILE: Kotlin.kt
fun box(): String {
val toString: String? = JavaClass().toString()
if (toString != null) return "fail 1: $toString"
val template: String? = "${JavaClass()}"
if (template != null) return "fail 2: $template"
return "OK"
}
@@ -0,0 +1,20 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KOTLIN_CONFIGURATION_FLAGS: STRING_CONCAT=indy-with-constants
// JVM_TARGET: 9
// FILE: JavaClass.java
public class JavaClass {
public String toString() {
return null;
}
}
// FILE: Kotlin.kt
fun box() {
val toString: String? = JavaClass().toString()
val template: String = "${JavaClass()}"
}
// 0 INVOKEDYNAMIC makeConcat
// 1 JavaClass.toString
// 1 String.valueOf
// 0 append
@@ -31974,6 +31974,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/strings/kt3652.kt");
}
@TestMetadata("kt42457_old.kt")
public void testKt42457_old() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt42457_old.kt");
}
@TestMetadata("kt5389_stringBuilderGet.kt")
public void testKt5389_stringBuilderGet() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt");
@@ -4583,6 +4583,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt19037.kt");
}
@TestMetadata("kt42457_old.kt")
public void testKt42457_old() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt42457_old.kt");
}
@TestMetadata("multipleNestedConcat.kt")
public void testMultipleNestedConcat() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt");
@@ -29608,6 +29608,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/strings/kt3652.kt");
}
@TestMetadata("kt42457_old.kt")
public void testKt42457_old() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt42457_old.kt");
}
@TestMetadata("kt5389_stringBuilderGet.kt")
public void testKt5389_stringBuilderGet() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt");
@@ -30208,6 +30208,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/strings/kt3652.kt");
}
@TestMetadata("kt42457_old.kt")
public void testKt42457_old() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt42457_old.kt");
}
@TestMetadata("kt5389_stringBuilderGet.kt")
public void testKt5389_stringBuilderGet() throws Exception {
runTest("compiler/testData/codegen/box/strings/kt5389_stringBuilderGet.kt");
@@ -4551,6 +4551,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt19037.kt");
}
@TestMetadata("kt42457_old.kt")
public void testKt42457_old() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt42457_old.kt");
}
@TestMetadata("multipleNestedConcat.kt")
public void testMultipleNestedConcat() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt");