Fix intrinsic for String.plus for explicit calls
#KT-14567 Fixed
This commit is contained in:
@@ -47,12 +47,12 @@ class Concat : IntrinsicMethod() {
|
||||
codegen.invokeAppend(element.right)
|
||||
}
|
||||
else {
|
||||
// LHS?.plus(RHS)
|
||||
receiver.put(AsmTypes.OBJECT_TYPE, v)
|
||||
// Explicit plus call LHS?.plus(RHS) or LHS.plus(RHS)
|
||||
receiver.put(AsmTypes.JAVA_STRING_TYPE, v)
|
||||
genStringBuilderConstructor(v)
|
||||
v.swap()
|
||||
genInvokeAppendMethod(v, returnType)
|
||||
codegen.invokeAppend(arguments.get(0))
|
||||
codegen.invokeAppend(arguments[0])
|
||||
}
|
||||
|
||||
v.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun bar1(): String {
|
||||
val l: List<String> = listOf("O")
|
||||
val s = l[0].plus("K")
|
||||
return s
|
||||
}
|
||||
|
||||
fun bar2(): String {
|
||||
val l: List<String?> = listOf("O")
|
||||
val s = l[0]?.plus("K")
|
||||
return s!!
|
||||
}
|
||||
|
||||
fun bar3(): String {
|
||||
val l: List<String> = listOf("O")
|
||||
with(l[0]) {
|
||||
return plus("K")
|
||||
}
|
||||
return "fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (bar1() != "OK") return "fail 1"
|
||||
if (bar2() != "OK") return "fail 2"
|
||||
if (bar3() != "OK") return "fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@kotlin.Metadata
|
||||
public final class PlusExplicitKt {
|
||||
public final static @org.jetbrains.annotations.NotNull method bar1(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method bar2(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method bar3(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+6
@@ -11207,6 +11207,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("plusExplicit.kt")
|
||||
public void testPlusExplicit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/plusExplicit.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("remAssignmentOperation.kt")
|
||||
public void testRemAssignmentOperation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/remAssignmentOperation.kt");
|
||||
|
||||
@@ -11207,6 +11207,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("plusExplicit.kt")
|
||||
public void testPlusExplicit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/plusExplicit.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("remAssignmentOperation.kt")
|
||||
public void testRemAssignmentOperation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/remAssignmentOperation.kt");
|
||||
|
||||
@@ -12936,6 +12936,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("plusExplicit.kt")
|
||||
public void testPlusExplicit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/plusExplicit.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("remAssignmentOperation.kt")
|
||||
public void testRemAssignmentOperation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/remAssignmentOperation.kt");
|
||||
|
||||
Reference in New Issue
Block a user