[Native] Move isRestrictedSuspendFunction from IrUtils2

This function is also helpful for JVM backend.
This commit is contained in:
Ivan Kylchik
2023-08-16 11:17:03 +02:00
committed by Space Team
parent 2657adc6dc
commit 5cd96831dc
4 changed files with 11 additions and 9 deletions
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.descriptors.impl.MutableClassDescriptor
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.checkers.isRestrictedSuspendFunction
import org.jetbrains.kotlin.resolve.calls.checkers.isRestrictsSuspensionReceiver
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.storage.LockBasedStorageManager
@@ -108,9 +109,7 @@ class JvmRuntimeTypes(
if (descriptor.isSuspend) {
return mutableListOf<KotlinType>().apply {
if (actualFunctionDescriptor.extensionReceiverParameter?.type
?.isRestrictsSuspensionReceiver() == true
) {
if (actualFunctionDescriptor.isRestrictedSuspendFunction()) {
if (descriptor.isSuspendLambdaOrLocalFunction()) {
add(restrictedSuspendLambda.defaultType)
} else {
@@ -144,6 +144,9 @@ fun KotlinType.isRestrictsSuspensionReceiver() = (listOf(this) + this.supertypes
) == true
}
fun FunctionDescriptor.isRestrictedSuspendFunction(): Boolean =
extensionReceiverParameter?.type?.isRestrictsSuspensionReceiver() == true
private fun checkRestrictsSuspension(
enclosingSuspendCallableDescriptor: CallableDescriptor,
resolvedCall: ResolvedCall<*>,