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) {
|
val resultingType: ConeKotlinType = when (fir) {
|
||||||
is FirFunction -> createKFunctionType(
|
is FirFunction -> createKFunctionType(
|
||||||
fir, resultingReceiverType, returnTypeRef,
|
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)
|
is FirVariable<*> -> createKPropertyType(fir, resultingReceiverType, returnTypeRef)
|
||||||
else -> ConeKotlinErrorType("Unknown callable kind: ${fir::class}")
|
else -> ConeKotlinErrorType("Unknown callable kind: ${fir::class}")
|
||||||
@@ -289,7 +290,8 @@ private fun createKFunctionType(
|
|||||||
function: FirFunction<*>,
|
function: FirFunction<*>,
|
||||||
receiverType: ConeKotlinType?,
|
receiverType: ConeKotlinType?,
|
||||||
returnTypeRef: FirResolvedTypeRef,
|
returnTypeRef: FirResolvedTypeRef,
|
||||||
expectedParameterNumberWithReceiver: Int?
|
expectedParameterNumberWithReceiver: Int?,
|
||||||
|
isSuspend: Boolean
|
||||||
): ConeKotlinType {
|
): ConeKotlinType {
|
||||||
val parameterTypes = mutableListOf<ConeKotlinType>()
|
val parameterTypes = mutableListOf<ConeKotlinType>()
|
||||||
val expectedParameterNumber = when {
|
val expectedParameterNumber = when {
|
||||||
@@ -307,7 +309,8 @@ private fun createKFunctionType(
|
|||||||
return createFunctionalType(
|
return createFunctionalType(
|
||||||
parameterTypes, receiverType = receiverType,
|
parameterTypes, receiverType = receiverType,
|
||||||
rawReturnType = returnTypeRef.coneTypeSafe() ?: ConeKotlinErrorType("No type for return type of $function"),
|
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
|
// IGNORE_BACKEND: NATIVE
|
||||||
// WITH_REFLECT
|
// WITH_REFLECT
|
||||||
// WITH_COROUTINES
|
// WITH_COROUTINES
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// WITH_COROUTINES
|
// 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
|
// !CHECK_TYPE
|
||||||
// !LANGUAGE: +ReleaseCoroutines
|
// !LANGUAGE: +ReleaseCoroutines
|
||||||
// SKIP_TXT
|
// SKIP_TXT
|
||||||
|
|||||||
Reference in New Issue
Block a user