From 78bb0be7aa2fff746d9826bca9826d17b986805e Mon Sep 17 00:00:00 2001 From: Brian Norman Date: Wed, 14 Feb 2024 11:18:39 -0600 Subject: [PATCH] [FIR2IR] Propagate NOT_IN statement origin when converting to IR ^KT-65636 Fixed --- .../src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt | 3 +++ compiler/testData/ir/irText/expressions/in.fir.ir.txt | 4 ++-- .../ir/irText/expressions/whenWithSubjectVariable.fir.ir.txt | 2 +- .../testData/codegen/operator/NegativeContainsOperator.kt | 3 --- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 28da9f88315..23b0683d40e 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -535,6 +535,9 @@ internal fun FirReference.statementOrigin(): IrStatementOrigin? = when (this) { source?.kind == KtFakeSourceElementKind.DesugaredForLoop && symbol.callableId.isIterator() -> IrStatementOrigin.FOR_LOOP_ITERATOR + source?.kind == KtFakeSourceElementKind.DesugaredInvertedContains -> + IrStatementOrigin.NOT_IN + source?.kind is KtFakeSourceElementKind.DesugaredIncrementOrDecrement -> incOrDeclSourceKindToIrStatementOrigin[source?.kind] diff --git a/compiler/testData/ir/irText/expressions/in.fir.ir.txt b/compiler/testData/ir/irText/expressions/in.fir.ir.txt index 7d14c7e39db..807487b63cd 100644 --- a/compiler/testData/ir/irText/expressions/in.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/in.fir.ir.txt @@ -12,7 +12,7 @@ FILE fqName: fileName:/in.kt VALUE_PARAMETER name:x index:1 type:kotlin.collections.Collection BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any, x: kotlin.collections.Collection): kotlin.Boolean declared in ' - CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=null + CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=NOT_IN $this: CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.Collection' type=kotlin.Boolean origin=IN $this: GET_VAR 'x: kotlin.collections.Collection declared in .test2' type=kotlin.collections.Collection origin=null element: GET_VAR 'a: kotlin.Any declared in .test2' type=kotlin.Any origin=null @@ -31,7 +31,7 @@ FILE fqName: fileName:/in.kt VALUE_PARAMETER name:x index:1 type:kotlin.collections.Collection.test4> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (a: T of .test4, x: kotlin.collections.Collection.test4>): kotlin.Boolean declared in ' - CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=null + CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=NOT_IN $this: CALL 'public abstract fun contains (element: E of kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.Collection' type=kotlin.Boolean origin=IN $this: GET_VAR 'x: kotlin.collections.Collection.test4> declared in .test4' type=kotlin.collections.Collection.test4> origin=null element: GET_VAR 'a: T of .test4 declared in .test4' type=T of .test4 origin=null diff --git a/compiler/testData/ir/irText/expressions/whenWithSubjectVariable.fir.ir.txt b/compiler/testData/ir/irText/expressions/whenWithSubjectVariable.fir.ir.txt index 128f051f08d..3263a998630 100644 --- a/compiler/testData/ir/irText/expressions/whenWithSubjectVariable.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/whenWithSubjectVariable.fir.ir.txt @@ -34,7 +34,7 @@ FILE fqName: fileName:/whenWithSubjectVariable.kt GET_VAR 'val y: kotlin.Any declared in .test' type=kotlin.Any origin=null then: CONST Int type=kotlin.Int value=3 BRANCH - if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=null + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=NOT_IN $this: CALL 'public open fun contains (value: kotlin.Int): kotlin.Boolean declared in kotlin.ranges.IntRange' type=kotlin.Boolean origin=IN $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE $this: CONST Int type=kotlin.Int value=10 diff --git a/plugins/power-assert/testData/codegen/operator/NegativeContainsOperator.kt b/plugins/power-assert/testData/codegen/operator/NegativeContainsOperator.kt index 3d7f6d2bd4b..992a48ac7f9 100644 --- a/plugins/power-assert/testData/codegen/operator/NegativeContainsOperator.kt +++ b/plugins/power-assert/testData/codegen/operator/NegativeContainsOperator.kt @@ -1,6 +1,3 @@ -// IGNORE_BACKEND_K2: JVM_IR -// K2 disabled because of KT-65636 - fun box() = expectThrowableMessage { assert("Hello" !in listOf("Hello", "World")) }