diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 557c8806dbe..293e564b018 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -902,7 +902,7 @@ class Fir2IrVisitor( } val calleeReference = (functionCall.calleeReference as? FirResolvedNamedReference) ?: return functionCall val resolvedSymbol = (calleeReference.resolvedSymbol as? FirNamedFunctionSymbol) ?: return functionCall - if (resolvedSymbol.callableId.isInvoke()) { + if (resolvedSymbol.callableId.isInvoke() || resolvedSymbol.callableId.isIteratorNext()) { functionCall.calleeReference = buildResolvedNamedReference { source = calleeReference.source diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index a4d090421cd..4b8b8776f16 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -470,4 +470,7 @@ fun CallableId.isInvoke() = fun CallableId.isKFunctionInvoke() = callableName.asString() == "invoke" && className?.asString()?.startsWith("KFunction") == true - && packageName.asString() == "kotlin.reflect" \ No newline at end of file + && packageName.asString() == "kotlin.reflect" + +fun CallableId.isIteratorNext() = + callableName.asString() == "next" && className?.asString()?.equals("Iterator") == true && packageName.asString() == "kotlin.collections" diff --git a/compiler/testData/codegen/box/controlStructures/breakContinueInExpressions/kt17384.kt b/compiler/testData/codegen/box/controlStructures/breakContinueInExpressions/kt17384.kt index f91e2ca50d4..21aa85b6baa 100644 --- a/compiler/testData/codegen/box/controlStructures/breakContinueInExpressions/kt17384.kt +++ b/compiler/testData/codegen/box/controlStructures/breakContinueInExpressions/kt17384.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun returnNullable(): String? = null inline fun Array.matchAll(fn: (String) -> Unit) { diff --git a/compiler/testData/codegen/box/controlStructures/kt3574.kt b/compiler/testData/codegen/box/controlStructures/kt3574.kt index 397546500c4..ce0f4fbd177 100644 --- a/compiler/testData/codegen/box/controlStructures/kt3574.kt +++ b/compiler/testData/codegen/box/controlStructures/kt3574.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM fun nil() = null diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariableFailFast.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariableFailFast.kt index 986c8ec55c3..027fd237ef0 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariableFailFast.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariableFailFast.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/secondaryConstructors/withVarargs.kt b/compiler/testData/codegen/box/secondaryConstructors/withVarargs.kt index 1b77f6428fd..84b0f3feba8 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/withVarargs.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/withVarargs.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FILE: WithVarargs.java diff --git a/compiler/testData/codegen/box/vararg/singleAssignmentToVarargsInFunction.kt b/compiler/testData/codegen/box/vararg/singleAssignmentToVarargsInFunction.kt index 0ebfa09e668..b41ddc0c46d 100644 --- a/compiler/testData/codegen/box/vararg/singleAssignmentToVarargsInFunction.kt +++ b/compiler/testData/codegen/box/vararg/singleAssignmentToVarargsInFunction.kt @@ -1,5 +1,4 @@ // !LANGUAGE: -ProhibitAssigningSingleElementsToVarargsInNamedForm -// IGNORE_BACKEND_FIR: JVM_IR fun box(): String { if (test1(p = 1) != "1") return "fail 1" diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt index dea7b68b140..58b2f869c39 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt @@ -69,7 +69,7 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt $this: GET_VAR 'val tmp_4: kotlin.collections.Iterator [val] declared in .test3' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:s type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_4: kotlin.collections.Iterator [val] declared in .test3' type=kotlin.collections.Iterator origin=null FUN name:test4 visibility:public modality:FINAL <> (ss:kotlin.collections.List?) returnType:kotlin.Unit VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List? @@ -99,7 +99,7 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt $this: GET_VAR 'val tmp_7: kotlin.collections.Iterator [val] declared in .test4' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:s type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_7: kotlin.collections.Iterator [val] declared in .test4' type=kotlin.collections.Iterator origin=null FUN name:test5 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/for.fir.txt b/compiler/testData/ir/irText/expressions/for.fir.txt index 256b3654b2a..bcd1d9402a1 100644 --- a/compiler/testData/ir/irText/expressions/for.fir.txt +++ b/compiler/testData/ir/irText/expressions/for.fir.txt @@ -12,7 +12,7 @@ FILE fqName: fileName:/for.kt $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator [val] declared in .testEmpty' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:s type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator [val] declared in .testEmpty' type=kotlin.collections.Iterator origin=null FUN name:testIterable visibility:public modality:FINAL <> (ss:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List @@ -27,7 +27,7 @@ FILE fqName: fileName:/for.kt $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator [val] declared in .testIterable' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:s type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator [val] declared in .testIterable' type=kotlin.collections.Iterator origin=null CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null message: GET_VAR 'val s: kotlin.String [val] declared in .testIterable' type=kotlin.String origin=null @@ -44,7 +44,7 @@ FILE fqName: fileName:/for.kt $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator> [val] declared in .testDestructuring' type=kotlin.collections.Iterator> origin=null body: BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Pair [val] - CALL 'public abstract fun next (): kotlin.Pair [operator] declared in kotlin.collections.Iterator' type=kotlin.Pair origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.Pair origin=null $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator> [val] declared in .testDestructuring' type=kotlin.collections.Iterator> origin=null VAR name:i type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int [operator] declared in kotlin.Pair' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt index 29a2b281538..8e48cf5a717 100644 --- a/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt +++ b/compiler/testData/ir/irText/expressions/forWithBreakContinue.fir.txt @@ -12,7 +12,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator [val] declared in .testForBreak1' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Nothing origin=null VAR name:s type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator [val] declared in .testForBreak1' type=kotlin.collections.Iterator origin=null BREAK label=null loop.label=null FUN name:testForBreak2 visibility:public modality:FINAL <> (ss:kotlin.collections.List) returnType:kotlin.Unit @@ -28,7 +28,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator [val] declared in .testForBreak2' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Nothing origin=null VAR name:s1 type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator [val] declared in .testForBreak2' type=kotlin.collections.Iterator origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.collections.List [val] GET_VAR 'ss: kotlin.collections.List declared in .testForBreak2' type=kotlin.collections.List origin=null @@ -40,7 +40,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator [val] declared in .testForBreak2' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Nothing origin=null VAR name:s2 type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator [val] declared in .testForBreak2' type=kotlin.collections.Iterator origin=null BREAK label=OUTER loop.label=OUTER BREAK label=INNER loop.label=INNER @@ -59,7 +59,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_7: kotlin.collections.Iterator [val] declared in .testForContinue1' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Nothing origin=null VAR name:s type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_7: kotlin.collections.Iterator [val] declared in .testForContinue1' type=kotlin.collections.Iterator origin=null CONTINUE label=null loop.label=null FUN name:testForContinue2 visibility:public modality:FINAL <> (ss:kotlin.collections.List) returnType:kotlin.Unit @@ -75,7 +75,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_9: kotlin.collections.Iterator [val] declared in .testForContinue2' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Nothing origin=null VAR name:s1 type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_9: kotlin.collections.Iterator [val] declared in .testForContinue2' type=kotlin.collections.Iterator origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:kotlin.collections.List [val] GET_VAR 'ss: kotlin.collections.List declared in .testForContinue2' type=kotlin.collections.List origin=null @@ -87,7 +87,7 @@ FILE fqName: fileName:/forWithBreakContinue.kt $this: GET_VAR 'val tmp_11: kotlin.collections.Iterator [val] declared in .testForContinue2' type=kotlin.collections.Iterator origin=null body: BLOCK type=kotlin.Nothing origin=null VAR name:s2 type:kotlin.String [val] - CALL 'public abstract fun next (): kotlin.String [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=null $this: GET_VAR 'val tmp_11: kotlin.collections.Iterator [val] declared in .testForContinue2' type=kotlin.collections.Iterator origin=null CONTINUE label=OUTER loop.label=OUTER CONTINUE label=INNER loop.label=INNER diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt index 97c0c11052e..2cae9b3e75e 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt @@ -14,7 +14,7 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<.P> origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:x type:.P [val] - CALL 'public abstract fun next (): .P [operator] declared in kotlin.collections.Iterator' type=.P origin=null + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=null $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<.P> origin=null FUN name:testForInListDestructured visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY @@ -28,7 +28,7 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt $this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<.P> origin=null body: BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:.P [val] - CALL 'public abstract fun next (): .P [operator] declared in kotlin.collections.Iterator' type=.P origin=null + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=null $this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<.P> origin=null VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int declared in .P' type=kotlin.Int origin=null @@ -46,7 +46,7 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<.P> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<.P> origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:x type:.P [val] - CALL 'public abstract fun next (): .P [operator] declared in kotlin.collections.Iterator' type=.P origin=null + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=null $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<.P> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<.P> origin=null FUN name:testForInArrayUnused visibility:public modality:FINAL <> (j:.J) returnType:kotlin.Unit VALUE_PARAMETER name:j index:0 type:.J @@ -62,7 +62,7 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt $this: GET_VAR 'val tmp_6: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUnused' type=kotlin.collections.Iterator<.P?> origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:x type:.P? [val] - CALL 'public abstract fun next (): .P? [operator] declared in kotlin.collections.Iterator' type=.P? origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=null $this: GET_VAR 'val tmp_6: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUnused' type=kotlin.collections.Iterator<.P?> origin=null FUN name:testForInListUse visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY @@ -76,7 +76,7 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt $this: GET_VAR 'val tmp_8: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<.P> origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:x type:.P [val] - CALL 'public abstract fun next (): .P [operator] declared in kotlin.collections.Iterator' type=.P origin=null + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=null $this: GET_VAR 'val tmp_8: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<.P> origin=null CALL 'public final fun use (s: .P): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: GET_VAR 'val x: .P [val] declared in .testForInListUse' type=.P origin=null @@ -96,7 +96,7 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt $this: GET_VAR 'val tmp_10: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUse' type=kotlin.collections.Iterator<.P?> origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:x type:.P? [val] - CALL 'public abstract fun next (): .P? [operator] declared in kotlin.collections.Iterator' type=.P? origin=null + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=null $this: GET_VAR 'val tmp_10: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUse' type=kotlin.collections.Iterator<.P?> origin=null CALL 'public final fun use (s: .P): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: GET_VAR 'val x: .P? [val] declared in .testForInArrayUse' type=.P? origin=null