FIR: handle suspend functions in callable reference resolve properly
This commit is contained in:
@@ -233,7 +233,8 @@ internal object CheckCallableReferenceExpectedType : CheckerStage() {
|
||||
val resultingType: ConeKotlinType = when (fir) {
|
||||
is FirFunction -> createKFunctionType(
|
||||
fir, resultingReceiverType, returnTypeRef,
|
||||
expectedParameterNumberWithReceiver = expectedType?.let { it.typeArguments.size - 1 }
|
||||
expectedParameterNumberWithReceiver = expectedType?.let { it.typeArguments.size - 1 },
|
||||
isSuspend = (fir as? FirSimpleFunction)?.isSuspend == true
|
||||
)
|
||||
is FirVariable<*> -> createKPropertyType(fir, resultingReceiverType, returnTypeRef)
|
||||
else -> ConeKotlinErrorType("Unknown callable kind: ${fir::class}")
|
||||
@@ -289,7 +290,8 @@ private fun createKFunctionType(
|
||||
function: FirFunction<*>,
|
||||
receiverType: ConeKotlinType?,
|
||||
returnTypeRef: FirResolvedTypeRef,
|
||||
expectedParameterNumberWithReceiver: Int?
|
||||
expectedParameterNumberWithReceiver: Int?,
|
||||
isSuspend: Boolean
|
||||
): ConeKotlinType {
|
||||
val parameterTypes = mutableListOf<ConeKotlinType>()
|
||||
val expectedParameterNumber = when {
|
||||
@@ -307,7 +309,8 @@ private fun createKFunctionType(
|
||||
return createFunctionalType(
|
||||
parameterTypes, receiverType = receiverType,
|
||||
rawReturnType = returnTypeRef.coneTypeSafe() ?: ConeKotlinErrorType("No type for return type of $function"),
|
||||
isKFunctionType = true
|
||||
isKFunctionType = true,
|
||||
isSuspend = isSuspend
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// WITH_REFLECT
|
||||
// WITH_COROUTINES
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !LANGUAGE: +ReleaseCoroutines
|
||||
// SKIP_TXT
|
||||
|
||||
import kotlin.reflect.KSuspendFunction0
|
||||
|
||||
suspend fun foo() {}
|
||||
|
||||
fun test() {
|
||||
::foo checkType { <!INAPPLICABLE_CANDIDATE!>_<!><KSuspendFunction0<Unit>>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !LANGUAGE: +ReleaseCoroutines
|
||||
// SKIP_TXT
|
||||
|
||||
Reference in New Issue
Block a user