[Native] Support multiple suspend lambdas as class supertypes

Drop the backend check. Eveything else is already fixed in
https://github.com/JetBrains/kotlin/commit/3b3318ab06e8c55b1c49da5734decd59524c3d9f

^KT-46775
This commit is contained in:
Dmitriy Dolovov
2021-05-18 17:47:24 +03:00
parent 896929cb21
commit ae1590d3cf
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.backend.konan.ir.companionObject
import org.jetbrains.kotlin.backend.konan.ir.getSuperClassNotAny
import org.jetbrains.kotlin.backend.konan.llvm.IntrinsicType
import org.jetbrains.kotlin.backend.konan.llvm.tryGetIntrinsicType
import org.jetbrains.kotlin.builtins.functions.FunctionClassKind
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
@@ -29,7 +28,6 @@ import org.jetbrains.kotlin.descriptors.isFinalClass
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
@@ -593,41 +591,9 @@ private class BackendChecker(val context: Context, val irFile: IrFile) : IrEleme
if (declaration.isKotlinObjCClass()) {
checkKotlinObjCClass(declaration)
}
checkNotImplementsMultipleSuspendLambdas(declaration)
}
}
// TODO: remove this check in KT-46775
private fun BackendChecker.checkNotImplementsMultipleSuspendLambdas(clazz: IrClass) {
var suspendFunctionClassSymbol: IrClassSymbol? = null // Can be null (no suspend function supertypes) or non-null (the single one).
fun checkSupertype(superType: IrType): Boolean {
val superTypeClassSymbol = superType.classOrNull
?: return true // This is not a class. Continue with others.
return when {
superTypeClassSymbol.isFunctionMarker() -> true // Continue with others.
superTypeClassSymbol.isFunction() -> {
// Mixing suspend and non-suspend function supertypes is not allowed by the frontend. So can stop here.
false
}
superTypeClassSymbol.isSuspendFunction() -> {
suspendFunctionClassSymbol = when (suspendFunctionClassSymbol) {
null, superTypeClassSymbol -> superTypeClassSymbol
else -> reportError(clazz, "Multiple suspend function types as supertypes are not supported yet")
}
true // Continue with others.
}
else -> {
// Recurse with supertypes.
superTypeClassSymbol.owner.superTypes.all(::checkSupertype)
}
}
}
clazz.superTypes.all(::checkSupertype)
}
private fun BackendChecker.checkCanGenerateCCall(expression: IrCall, isInvoke: Boolean) {
val callee = expression.symbol.owner