diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt index e9df9354279..a9950bdfdb1 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt @@ -48,6 +48,7 @@ object StandardClassIds { val KMutableProperty1 = "KMutableProperty1".reflectId() val KProperty2 = "KProperty2".reflectId() val KMutableProperty2 = "KMutableProperty2".reflectId() + val KFunction = "KFunction".reflectId() val Comparable = "Comparable".baseId() val Number = "Number".baseId() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt index 20e270a832d..eefcd1339b7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt @@ -227,20 +227,28 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: } superTypeRefs += when (kind) { - FunctionClassDescriptor.Kind.Function -> + FunctionClassDescriptor.Kind.Function -> listOf( buildResolvedTypeRef { type = ConeClassLikeLookupTagImpl(StandardClassIds.Function) .constructClassType(arrayOf(typeArguments.last().type), isNullable = false) } + ) - FunctionClassDescriptor.Kind.SuspendFunction -> + FunctionClassDescriptor.Kind.SuspendFunction -> listOf( session.builtinTypes.anyType + ) - FunctionClassDescriptor.Kind.KFunction -> + FunctionClassDescriptor.Kind.KFunction -> listOf( + buildResolvedTypeRef { + type = ConeClassLikeLookupTagImpl(StandardClassIds.KFunction) + .constructClassType(arrayOf(typeArguments.last().type), isNullable = false) + }, createSuperType(FunctionClassDescriptor.Kind.Function) + ) - FunctionClassDescriptor.Kind.KSuspendFunction -> + FunctionClassDescriptor.Kind.KSuspendFunction -> listOf( createSuperType(FunctionClassDescriptor.Kind.SuspendFunction) + ) } addDeclaration( buildSimpleFunction { diff --git a/compiler/testData/codegen/box/callableReference/bound/kCallableNameIntrinsic.kt b/compiler/testData/codegen/box/callableReference/bound/kCallableNameIntrinsic.kt index 3669473e6d0..557e76d4377 100644 --- a/compiler/testData/codegen/box/callableReference/bound/kCallableNameIntrinsic.kt +++ b/compiler/testData/codegen/box/callableReference/bound/kCallableNameIntrinsic.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // SKIP_SOURCEMAP_REMAPPING fun box(): String { diff --git a/compiler/testData/codegen/box/callableReference/function/local/localFunctionName.kt b/compiler/testData/codegen/box/callableReference/function/local/localFunctionName.kt index dbdbf212bb0..361ba4c3ce3 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/localFunctionName.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/localFunctionName.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - fun box(): String { fun OK() {} diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt index 95385560a35..20cb9d58063 100644 --- a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import kotlin.test.* diff --git a/compiler/testData/codegen/box/reflection/call/bound/javaInstanceMethod.kt b/compiler/testData/codegen/box/reflection/call/bound/javaInstanceMethod.kt index 4a69c45ca47..b75a03a5709 100644 --- a/compiler/testData/codegen/box/reflection/call/bound/javaInstanceMethod.kt +++ b/compiler/testData/codegen/box/reflection/call/bound/javaInstanceMethod.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TODO: investigate should it be ran for JS or not // TARGET_BACKEND: JVM diff --git a/compiler/testData/codegen/box/reflection/call/callInstanceJavaMethod.kt b/compiler/testData/codegen/box/reflection/call/callInstanceJavaMethod.kt index de15bad1322..d8fd46c863d 100644 --- a/compiler/testData/codegen/box/reflection/call/callInstanceJavaMethod.kt +++ b/compiler/testData/codegen/box/reflection/call/callInstanceJavaMethod.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/call/callStaticJavaMethod.kt b/compiler/testData/codegen/box/reflection/call/callStaticJavaMethod.kt index 0945433e3ce..ba6796187b7 100644 --- a/compiler/testData/codegen/box/reflection/call/callStaticJavaMethod.kt +++ b/compiler/testData/codegen/box/reflection/call/callStaticJavaMethod.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt b/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt index d1d709a1176..dc556686aa3 100644 --- a/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt +++ b/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.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/reflection/call/simpleConstructor.kt b/compiler/testData/codegen/box/reflection/call/simpleConstructor.kt index 89d7871363a..3a3397b1b93 100644 --- a/compiler/testData/codegen/box/reflection/call/simpleConstructor.kt +++ b/compiler/testData/codegen/box/reflection/call/simpleConstructor.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/reflection/callBy/simpleConstructor.kt b/compiler/testData/codegen/box/reflection/callBy/simpleConstructor.kt index 3e295271d72..437da745b95 100644 --- a/compiler/testData/codegen/box/reflection/callBy/simpleConstructor.kt +++ b/compiler/testData/codegen/box/reflection/callBy/simpleConstructor.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/reflection/constructors/constructorName.kt b/compiler/testData/codegen/box/reflection/constructors/constructorName.kt index fe393425020..37a9aaa3759 100644 --- a/compiler/testData/codegen/box/reflection/constructors/constructorName.kt +++ b/compiler/testData/codegen/box/reflection/constructors/constructorName.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt b/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt index 2dbd00a241c..c033c2daf6c 100644 --- a/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt +++ b/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR, JS, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/functions/javaMethodsSmokeTest.kt b/compiler/testData/codegen/box/reflection/functions/javaMethodsSmokeTest.kt index b913c8f1359..513242ff191 100644 --- a/compiler/testData/codegen/box/reflection/functions/javaMethodsSmokeTest.kt +++ b/compiler/testData/codegen/box/reflection/functions/javaMethodsSmokeTest.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/functions/platformName.kt b/compiler/testData/codegen/box/reflection/functions/platformName.kt index c60e909f9e0..4d54e0e1686 100644 --- a/compiler/testData/codegen/box/reflection/functions/platformName.kt +++ b/compiler/testData/codegen/box/reflection/functions/platformName.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/functions/simpleNames.kt b/compiler/testData/codegen/box/reflection/functions/simpleNames.kt index 3867b8946e4..9df53d8ee51 100644 --- a/compiler/testData/codegen/box/reflection/functions/simpleNames.kt +++ b/compiler/testData/codegen/box/reflection/functions/simpleNames.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_REFLECT import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/reflection/mapping/types/rawTypeArgument.kt b/compiler/testData/codegen/box/reflection/mapping/types/rawTypeArgument.kt index 72b25114d03..dff36ee7e4e 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/rawTypeArgument.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/rawTypeArgument.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/modifiers/javaVisibility.kt b/compiler/testData/codegen/box/reflection/modifiers/javaVisibility.kt index 4467e348b61..7390ae10760 100644 --- a/compiler/testData/codegen/box/reflection/modifiers/javaVisibility.kt +++ b/compiler/testData/codegen/box/reflection/modifiers/javaVisibility.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/noReflectAtRuntime/methodsFromAny/callableReferences.kt b/compiler/testData/codegen/box/reflection/noReflectAtRuntime/methodsFromAny/callableReferences.kt index 8d21b4a9921..b1506e32950 100644 --- a/compiler/testData/codegen/box/reflection/noReflectAtRuntime/methodsFromAny/callableReferences.kt +++ b/compiler/testData/codegen/box/reflection/noReflectAtRuntime/methodsFromAny/callableReferences.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 diff --git a/compiler/testData/codegen/box/reflection/parameters/realParameterNames.kt b/compiler/testData/codegen/box/reflection/parameters/realParameterNames.kt index b2ddc5b0f53..e582ee69a7c 100644 --- a/compiler/testData/codegen/box/reflection/parameters/realParameterNames.kt +++ b/compiler/testData/codegen/box/reflection/parameters/realParameterNames.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // SKIP_JDK6 // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/parameters/synthesizedParameterNames.kt b/compiler/testData/codegen/box/reflection/parameters/synthesizedParameterNames.kt index 099ad712e7e..82609f62477 100644 --- a/compiler/testData/codegen/box/reflection/parameters/synthesizedParameterNames.kt +++ b/compiler/testData/codegen/box/reflection/parameters/synthesizedParameterNames.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // SKIP_JDK6 // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/types/platformTypeToString.kt b/compiler/testData/codegen/box/reflection/types/platformTypeToString.kt index 5b814f3e328..e339364b397 100644 --- a/compiler/testData/codegen/box/reflection/types/platformTypeToString.kt +++ b/compiler/testData/codegen/box/reflection/types/platformTypeToString.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.fir.kt index 2ecb137ed46..67b2957ffb7 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.fir.kt @@ -17,7 +17,7 @@ fun main() { checkSubtype>(y) checkSubtype>(z) - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.fir.kt index fdbe223f494..206170c361c 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.fir.kt @@ -17,7 +17,7 @@ fun main() { checkSubtype>(y) checkSubtype>(z) - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.fir.txt index ed1126616f3..a5531dd449b 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.fir.txt @@ -57,17 +57,17 @@ FILE fqName: fileName:/funWithDefaultParametersAsKCallableStar.kt BLOCK_BODY FUN name:testDefaultsOnlyStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun defaultsOnly (x: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + fn: FUNCTION_REFERENCE 'public final fun defaultsOnly (x: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN name:testRegularAndDefaultsStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun regularAndDefaults (x1: kotlin.String, x2: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + fn: FUNCTION_REFERENCE 'public final fun regularAndDefaults (x1: kotlin.String, x2: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN name:testVarargsStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun varargs (vararg xs: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction1, kotlin.Int> origin=null reflectionTarget= + CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + fn: FUNCTION_REFERENCE 'public final fun varargs (vararg xs: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction1, kotlin.Int> origin=null reflectionTarget= FUN name:testCtorStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public constructor (x: kotlin.String) [primary] declared in .C' type=kotlin.reflect.KFunction0<.C> origin=null reflectionTarget= + CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + fn: FUNCTION_REFERENCE 'public constructor (x: kotlin.String) [primary] declared in .C' type=kotlin.reflect.KFunction0<.C> origin=null reflectionTarget=