JVM_IR KT-46060 'contains' operator without receiver is non-optimizable
This commit is contained in:
committed by
TeamCityServer
parent
21a3a14289
commit
531a0de399
+6
@@ -28863,6 +28863,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/inUntilMinValueNonConst.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmStaticContainsInObject.kt")
|
||||
public void testJvmStaticContainsInObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/jvmStaticContainsInObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt20106.kt")
|
||||
public void testKt20106() throws Exception {
|
||||
|
||||
+2
-2
@@ -98,8 +98,8 @@ private class Transformer(
|
||||
|
||||
// The HeaderInfoBuilder extracts information (e.g., lower/upper bounds, direction) from the range expression, which is the
|
||||
// receiver for the contains() call.
|
||||
val receiver = expression.dispatchReceiver ?: expression.extensionReceiver!!
|
||||
val headerInfo = receiver.accept(headerInfoBuilder, expression)
|
||||
val receiver = expression.dispatchReceiver ?: expression.extensionReceiver
|
||||
val headerInfo = receiver?.accept(headerInfoBuilder, expression)
|
||||
?: return super.visitCall(expression) // The receiver is not a supported range (or not a range at all).
|
||||
|
||||
val argument = expression.getValueArgument(0)!!
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
|
||||
object O {
|
||||
@JvmStatic
|
||||
operator fun contains(x: String): Boolean = x == "O"
|
||||
}
|
||||
|
||||
fun box() =
|
||||
if ("O" in O) "OK" else "Failed"
|
||||
+6
@@ -28845,6 +28845,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/inUntilMinValueNonConst.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmStaticContainsInObject.kt")
|
||||
public void testJvmStaticContainsInObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/jvmStaticContainsInObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt20106.kt")
|
||||
public void testKt20106() throws Exception {
|
||||
|
||||
+6
@@ -28863,6 +28863,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/inUntilMinValueNonConst.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmStaticContainsInObject.kt")
|
||||
public void testJvmStaticContainsInObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/jvmStaticContainsInObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt20106.kt")
|
||||
public void testKt20106() throws Exception {
|
||||
|
||||
+5
@@ -24537,6 +24537,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/inUntilMinValueNonConst.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmStaticContainsInObject.kt")
|
||||
public void testJvmStaticContainsInObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/jvmStaticContainsInObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt20106.kt")
|
||||
public void testKt20106() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/contains/kt20106.kt");
|
||||
|
||||
Reference in New Issue
Block a user