diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 6929977880b..76a958b75bb 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -144,6 +144,12 @@ class Fir2IrDeclarationStorage( leaveScope(descriptor) } + private fun preCacheTypeParameters(owner: FirTypeParametersOwner) { + owner.typeParameters.mapIndexed { index, typeParameter -> + getIrTypeParameter(typeParameter, index) + } + } + private fun IrTypeParametersContainer.setTypeParameters(owner: FirTypeParametersOwner) { typeParameters = owner.typeParameters.mapIndexed { index, typeParameter -> getIrTypeParameter(typeParameter, index).apply { parent = this@setTypeParameters } @@ -468,6 +474,7 @@ class Fir2IrDeclarationStorage( val containerSource = function.containerSource val descriptor = containerSource?.let { WrappedFunctionDescriptorWithContainerSource(it) } ?: WrappedSimpleFunctionDescriptor() val updatedOrigin = if (function.symbol.callableId.isKFunctionInvoke()) IrDeclarationOrigin.FAKE_OVERRIDE else origin + preCacheTypeParameters(function) return function.convertWithOffsets { startOffset, endOffset -> enterScope(descriptor) val result = irSymbolTable.declareSimpleFunction(startOffset, endOffset, origin, descriptor) { symbol -> diff --git a/compiler/testData/codegen/box/boxingOptimization/casts.kt b/compiler/testData/codegen/box/boxingOptimization/casts.kt index d3ab371f507..47ce676892b 100644 --- a/compiler/testData/codegen/box/boxingOptimization/casts.kt +++ b/compiler/testData/codegen/box/boxingOptimization/casts.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/boxingOptimization/checkcastAndInstanceOf.kt b/compiler/testData/codegen/box/boxingOptimization/checkcastAndInstanceOf.kt index 58635c5a5cf..13abe878a1b 100644 --- a/compiler/testData/codegen/box/boxingOptimization/checkcastAndInstanceOf.kt +++ b/compiler/testData/codegen/box/boxingOptimization/checkcastAndInstanceOf.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/boxingOptimization/nullCheck.kt b/compiler/testData/codegen/box/boxingOptimization/nullCheck.kt index e91746a1702..4ba74af4165 100644 --- a/compiler/testData/codegen/box/boxingOptimization/nullCheck.kt +++ b/compiler/testData/codegen/box/boxingOptimization/nullCheck.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/boxingOptimization/variables.kt b/compiler/testData/codegen/box/boxingOptimization/variables.kt index 08bc9eb55d4..18f6bf3d71e 100644 --- a/compiler/testData/codegen/box/boxingOptimization/variables.kt +++ b/compiler/testData/codegen/box/boxingOptimization/variables.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt index 8b2ebdc73cd..ee45f6c8e61 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType -// IGNORE_BACKEND_FIR: JVM_IR fun foo(x: String, y: Char = 'K'): String = x + y diff --git a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt index 0e849a7816b..ebf3ee6cff6 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TODO: muted automatically, investigate should it be ran for JS or not // DONT_RUN_GENERATED_CODE: JS diff --git a/compiler/testData/codegen/box/jvm8/inlineFromAnotherFile.kt b/compiler/testData/codegen/box/jvm8/inlineFromAnotherFile.kt index 496d9aecff1..eb2e7f5d75f 100644 --- a/compiler/testData/codegen/box/jvm8/inlineFromAnotherFile.kt +++ b/compiler/testData/codegen/box/jvm8/inlineFromAnotherFile.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // JVM_TARGET: 1.8 //WITH_RUNTIME diff --git a/compiler/testData/codegen/box/regressions/intersectionAsLastLambda.kt b/compiler/testData/codegen/box/regressions/intersectionAsLastLambda.kt index 3f13e27a9c2..19ced178876 100644 --- a/compiler/testData/codegen/box/regressions/intersectionAsLastLambda.kt +++ b/compiler/testData/codegen/box/regressions/intersectionAsLastLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FILE: First.java diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt index 7f290015678..a48d7859bc4 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.fir.txt @@ -65,7 +65,7 @@ FILE fqName:test fileName:/boundInnerGenericConstructor.kt $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:foo visibility:public modality:FINAL (a:A of test.foo, b:B of test.foo, x:kotlin.Function2>) returnType:test.Foo.Inner [inline] TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] - TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:B index:1 variance: superTypes:[kotlin.Any?] VALUE_PARAMETER name:a index:0 type:A of test.foo VALUE_PARAMETER name:b index:1 type:B of test.foo VALUE_PARAMETER name:x index:2 type:kotlin.Function2> diff --git a/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt index 3839b8632fd..4b783de2395 100644 --- a/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt +++ b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/fixationOrder1.kt FUN name:foo visibility:public modality:FINAL () returnType:kotlin.Function1.foo, Y of .foo> TYPE_PARAMETER name:X index:0 variance: superTypes:[kotlin.Any?] - TYPE_PARAMETER name:Y index:0 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:Y index:1 variance: superTypes:[kotlin.Any?] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Function1.foo, Y of .foo> declared in ' CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null @@ -24,7 +24,7 @@ FILE fqName: fileName:/fixationOrder1.kt $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:check visibility:public modality:FINAL (x:T of .check, y:R of .check, f:kotlin.Function1.check, R of .check>) returnType:.Inv2.check, R of .check> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:R index:1 variance: superTypes:[kotlin.Any?] VALUE_PARAMETER name:x index:0 type:T of .check VALUE_PARAMETER name:y index:1 type:R of .check VALUE_PARAMETER name:f index:2 type:kotlin.Function1.check, R of .check> diff --git a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt index 2953a6952aa..697ab3a2250 100644 --- a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt +++ b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/builtinMap.kt FUN name:plus visibility:public modality:FINAL ($receiver:kotlin.collections.Map.plus, V1 of .plus>, pair:kotlin.Pair.plus, V1 of .plus>) returnType:kotlin.collections.Map.plus, V1 of .plus> TYPE_PARAMETER name:K1 index:0 variance: superTypes:[kotlin.Any?] - TYPE_PARAMETER name:V1 index:0 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:V1 index:1 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:kotlin.collections.Map.plus, V1 of .plus> VALUE_PARAMETER name:pair index:0 type:kotlin.Pair.plus, V1 of .plus> BLOCK_BODY