diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt index 429784d75d7..19e46f09931 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt @@ -23,7 +23,10 @@ fun ConeKotlinType.isBuiltinFunctionalType(session: FirSession): Boolean { if (this !is ConeClassLikeType) return false val classId = fullyExpandedType(session).lookupTag.classId val kind = FunctionClassDescriptor.Kind.byClassNamePrefix(classId.packageFqName, classId.relativeClassName.asString()) ?: return false - return kind == FunctionClassDescriptor.Kind.Function || kind == FunctionClassDescriptor.Kind.SuspendFunction + return kind == FunctionClassDescriptor.Kind.Function || + kind == FunctionClassDescriptor.Kind.KFunction || + kind == FunctionClassDescriptor.Kind.SuspendFunction || + kind == FunctionClassDescriptor.Kind.KSuspendFunction } @OptIn(ExperimentalContracts::class) @@ -34,7 +37,8 @@ fun ConeKotlinType.isSuspendFunctionType(session: FirSession): Boolean { if (this !is ConeClassLikeType) return false val classId = this.fullyExpandedType(session).lookupTag.classId val kind = FunctionClassDescriptor.Kind.byClassNamePrefix(classId.packageFqName, classId.relativeClassName.asString()) ?: return false - return kind == FunctionClassDescriptor.Kind.SuspendFunction + return kind == FunctionClassDescriptor.Kind.SuspendFunction || + kind == FunctionClassDescriptor.Kind.KSuspendFunction } fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef?, session: FirSession): ConeKotlinType? { diff --git a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt index b90a227d933..ed9a9b9b7c4 100644 --- a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt +++ b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt index 8c30683f2a4..64feed39415 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt @@ -68,7 +68,7 @@ fun main() { select(id1 { it.inv() }, id2 { x: Int -> }) selectWithInv(id1 { it.inv() }, id2(Inv { x: Int -> })) select(id1 { it.inv() }, id1 { x: Number -> TODO() }, id1(id2 { x: Int -> x })) - select(id1 { it.inv() }, id1 { x: Number -> TODO() }, id1(id2(::takeInt))) + select(id1 { it.inv() }, id1 { x: Number -> TODO() }, id1(id2(::takeInt))) select(id1 { x: Inv -> TODO() }, id1 { it.x.inv() }, id1 { x: Inv -> TODO() }) select(id1 { it }, id1 { x: Inv -> TODO() }, id1 { x: Inv -> TODO() }) select(id(id2 { it.inv() }), id(id { x: Int -> x })) @@ -184,20 +184,20 @@ fun main() { ")!>select(A3(), { it }, { a -> a }) ")!>select(A3(), ")!>A3::foo1) // Should be error as `A3::foo1` is `KFunction2`, but the remaining arguments are `KFuncion1` or `Function1` - ")!>select(A3(), ")!>A3::foo1, { a -> a }, { it -> it }) + ")!>select(A3(), ")!>A3::foo1, { a -> a }, { it -> it }) // It's OK because `A3::foo2` is from companion of `A3` - ")!>select(A3(), ")!>A3::foo2, { a -> a }, { it -> it }) + ")!>select(A3(), ")!>A3::foo2, { a -> a }, { it -> it }) & java.io.Serializable>")!>select(A4(), { x: Number -> "" }) & java.io.Serializable>")!>select(A5(), { x: Number, y: Int -> "" }) select(A2(), id { a, b, c -> a; b; c }) ")!>select(id(A3()), { it }, { a -> a }) ")!>select(A3(), id(")!>A3::foo1)) - ")!>select(A3(), ")!>A3::foo1, id { a -> a }, { it -> it }) - ")!>select(A3(), ")!>A3::foo1, { a -> a }, id { it -> it }) - ")!>select(id(A3()), id(")!>A3::foo1), { a -> a }, { it -> it }) - ")!>select(id(A3()), id(")!>A3::foo1), { a -> a }, id { it -> it }) + ")!>select(A3(), ")!>A3::foo1, id { a -> a }, { it -> it }) + ")!>select(A3(), ")!>A3::foo1, { a -> a }, id { it -> it }) + ")!>select(id(A3()), id(")!>A3::foo1), { a -> a }, { it -> it }) + ")!>select(id(A3()), id(")!>A3::foo1), { a -> a }, id { it -> it }) // If lambdas' parameters are specified explicitly, we don't report an error, because there is proper CST – Function - ")!>select(id(A3()), id(")!>A3::foo1), { a: Number -> a }) + ")!>select(id(A3()), id(")!>A3::foo1), { a: Number -> a }) ")!>select(id(A3()), id(")!>A3::foo1), id { a: Number -> a }) select(A4(), id { x: Number -> x }) ")!>select(id(A5()), id { x: Number, y: Int -> x;y }) @@ -222,7 +222,7 @@ fun main() { // Anonymous functions val x69: (C) -> Unit = selectB({ it }, { }, id(fun (x) { x })) - select(id1(fun(it) { it.inv() }), id1 { x: Number -> TODO() }, id1(id2(::takeInt))) + select(id1(fun(it) { it.inv() }), id1 { x: Number -> TODO() }, id1(id2(::takeInt))) select(id(fun (it) { it }), id(id<(Int) -> Unit> { x: Number -> Unit })) select(id(fun (it) { it.inv() }), id<(Int) -> Unit> { }) val x70: (Int) -> Unit = selectNumber(id(fun (it) { }), id {}, id {}) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt index 32829ab8ea4..76fd6e28d98 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt @@ -31,27 +31,27 @@ fun foo6(x: Float) {} fun foo6(x: Number) {} fun main() { - select(::foo, { it }) + select(::foo, { it }) select(id(::foo), { x: Number -> }, { it }) - val x1 = select(")!>id(::foo), ")!>id { x: Number -> x }) + val x1 = select(")!>id(::foo), ")!>id { x: Number -> x }) ")!>x1 - val x11 = select(id(::foo), id { x: Number -> }, id { it }) + val x11 = select(id(::foo), id { x: Number -> }, id { it }) ")!>x11 - select(id(::foo2), id { x: Int -> }, id { it }) + select(id(::foo2), id { x: Int -> }, id { it }) - select(id(")!>::foo3), id { x: Int -> }, id { it }) - select(id(")!>::foo3), id { x: Number -> }, id { it }) - select(id(")!>::foo3), id { x: Number -> }, id { x: Int -> }, id { it }) + select(id(")!>::foo3), id { x: Int -> }, id { it }) + select(id(")!>::foo3), id { x: Number -> }, id { it }) + select(id(")!>::foo3), id { x: Number -> }, id { x: Int -> }, id { it }) select(id(::foo4), id { x: A -> }, id { it }) select(id(::foo4), id { x: B -> }, id { it }) // Expected ambiguity select(id(::foo4), id { x: A -> }, id { x: B -> }, id { it }) - select(id(::foo5), id { x: A -> }, id { x: B -> }, id { it }) + select(id(::foo5), id { x: A -> }, id { x: B -> }, id { it }) val x2: (Int) -> Unit = selectNumber(id(")!>::foo6), id { x -> x }, id { it }) }