[FIR2IR] Fix considering of Contains intrinsic

This commit is contained in:
Ivan Kochurkin
2021-10-13 19:29:22 +03:00
committed by TeamCityServer
parent 15d23f2a72
commit 0d91e16a15
13 changed files with 8 additions and 17 deletions
@@ -440,7 +440,8 @@ private val nameToOperationConventionOrigin = mutableMapOf(
OperatorNameConventions.DIV to IrStatementOrigin.DIV,
OperatorNameConventions.MOD to IrStatementOrigin.PERC,
OperatorNameConventions.REM to IrStatementOrigin.PERC,
OperatorNameConventions.RANGE_TO to IrStatementOrigin.RANGE
OperatorNameConventions.RANGE_TO to IrStatementOrigin.RANGE,
OperatorNameConventions.CONTAINS to IrStatementOrigin.IN,
)
internal fun FirReference.statementOrigin(): IrStatementOrigin? {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun testPrimitiveArray(i: Int, ints: IntArray) = i in ints.indices
fun testObjectArray(i: Int, xs: Array<Any>) = i in xs.indices
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun testCharSequence(i: Int, cs: CharSequence) = i in cs.indices
fun testLongWithCharSequence(i: Long, cs: CharSequence) = i in cs.indices
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun testCollection(i: Int, xs: List<Any>) = i in xs.indices
fun testLongWithCollection(i: Long, xs: List<Any>) = i in xs.indices
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun test1(a: String) = a in "alpha" .. "omega"
fun test2(a: String) = a !in "alpha" .. "omega"
fun <T : Comparable<T>> test3(x: T, left: T, right: T) = x in left .. right
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun ub_ub(x: UByte, a: UByte, b: UByte) = x in a..b
fun ub_us(x: UByte, a: UShort, b: UShort) = x in a..b
fun ub_ui(x: UByte, a: UInt, b: UInt) = x in a..b
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// ULong in range of UInt, uses non-intrinsic 'contains' for non-IR backend
fun ul_ub(x: ULong, a: UByte, b: UByte) = x in a..b
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun inInt(x: Long): Boolean {
return x in 1..2
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun Byte.inByte(left: Byte, right: Byte) = this in left..right
fun Short.inInt(left: Int, right: Int) = this in left .. right
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun testUIntRangeLiteral(a: UInt, b: UInt) = 42u in a .. b
fun testULongRangeLiteral(a: ULong, b: ULong) = 42UL in a .. b
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun testChar(a: Char, x: Char, y: Char) = a in x until y
fun testByte(a: Byte, x: Byte, y: Byte) = a in x until y
+4 -4
View File
@@ -4,7 +4,7 @@ FILE fqName:<root> fileName:/in.kt
VALUE_PARAMETER name:x index:1 type:kotlin.collections.Collection<kotlin.Any>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any, x: kotlin.collections.Collection<kotlin.Any>): kotlin.Boolean declared in <root>'
CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=null
CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=IN
$this: GET_VAR 'x: kotlin.collections.Collection<kotlin.Any> declared in <root>.test1' type=kotlin.collections.Collection<kotlin.Any> origin=null
element: GET_VAR 'a: kotlin.Any declared in <root>.test1' type=kotlin.Any origin=null
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any, x:kotlin.collections.Collection<kotlin.Any>) returnType:kotlin.Boolean
@@ -13,7 +13,7 @@ FILE fqName:<root> fileName:/in.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any, x: kotlin.collections.Collection<kotlin.Any>): kotlin.Boolean declared in <root>'
CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null
$this: CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=null
$this: CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=IN
$this: GET_VAR 'x: kotlin.collections.Collection<kotlin.Any> declared in <root>.test2' type=kotlin.collections.Collection<kotlin.Any> origin=null
element: GET_VAR 'a: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
FUN name:test3 visibility:public modality:FINAL <T> (a:T of <root>.test3, x:kotlin.collections.Collection<T of <root>.test3>) returnType:kotlin.Boolean
@@ -22,7 +22,7 @@ FILE fqName:<root> fileName:/in.kt
VALUE_PARAMETER name:x index:1 type:kotlin.collections.Collection<T of <root>.test3>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test3 <T> (a: T of <root>.test3, x: kotlin.collections.Collection<T of <root>.test3>): kotlin.Boolean declared in <root>'
CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=null
CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=IN
$this: GET_VAR 'x: kotlin.collections.Collection<T of <root>.test3> declared in <root>.test3' type=kotlin.collections.Collection<T of <root>.test3> origin=null
element: GET_VAR 'a: T of <root>.test3 declared in <root>.test3' type=T of <root>.test3 origin=null
FUN name:test4 visibility:public modality:FINAL <T> (a:T of <root>.test4, x:kotlin.collections.Collection<T of <root>.test4>) returnType:kotlin.Boolean
@@ -32,6 +32,6 @@ FILE fqName:<root> fileName:/in.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test4 <T> (a: T of <root>.test4, x: kotlin.collections.Collection<T of <root>.test4>): kotlin.Boolean declared in <root>'
CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null
$this: CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=null
$this: CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean [operator] declared in kotlin.collections.Collection' type=kotlin.Boolean origin=IN
$this: GET_VAR 'x: kotlin.collections.Collection<T of <root>.test4> declared in <root>.test4' type=kotlin.collections.Collection<T of <root>.test4> origin=null
element: GET_VAR 'a: T of <root>.test4 declared in <root>.test4' type=T of <root>.test4 origin=null
+2 -2
View File
@@ -45,7 +45,7 @@ FILE fqName:<root> fileName:/when.kt
GET_VAR 'val tmp_0: kotlin.Any? [val] declared in <root>.testWithSubject' type=kotlin.Any? origin=null
then: CONST String type=kotlin.String value="!Number"
BRANCH
if: CALL 'public final fun contains <T> (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=null
if: CALL 'public final fun contains <T> (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=IN
<T>: kotlin.Any?
$receiver: CALL 'public final fun setOf <T> (): kotlin.collections.Set<T of kotlin.collections.SetsKt.setOf> [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.Set<kotlin.Nothing> origin=null
<T>: kotlin.Nothing
@@ -78,7 +78,7 @@ FILE fqName:<root> fileName:/when.kt
GET_VAR 'x: kotlin.Any? declared in <root>.test' type=kotlin.Any? origin=null
then: CONST String type=kotlin.String value="!Number"
BRANCH
if: CALL 'public final fun contains <T> (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=null
if: CALL 'public final fun contains <T> (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=IN
<T>: kotlin.Number
$receiver: CALL 'public final fun setOf <T> (): kotlin.collections.Set<T of kotlin.collections.SetsKt.setOf> [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.Set<kotlin.Nothing> origin=null
<T>: kotlin.Nothing