Fix deserialization of kotlin.suspend when LV=1.3 is used
Before this change, kotlin.suspend was being loaded as having a common function type instead of suspend function type. With LV=1.3, we expect that suspend function types should have new Continuation interface as a last type argument, while kotlin.suspend is built with LV=1.2 and has old Continuation. This change might be reverted once stdlib will be rebuilt with LV=1.3 NB: kotlin.suspend doesn't need to be intrinsified since it only returns its parameter with checkcast to kotlinin.jvm.functions.Function1 (i.e., it doesn't refer the coroutines package) #KT-24861 Fixed
This commit is contained in:
+12
-1
@@ -13,9 +13,11 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedAnnotationsWithPossibleTargets
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import java.util.*
|
||||
|
||||
class TypeDeserializer(
|
||||
@@ -164,7 +166,16 @@ class TypeDeserializer(
|
||||
): SimpleType? {
|
||||
val functionType = KotlinTypeFactory.simpleType(annotations, functionTypeConstructor, arguments, nullable)
|
||||
if (!functionType.isFunctionType) return null
|
||||
return transformRuntimeFunctionTypeToSuspendFunction(functionType, isReleaseCoroutines)
|
||||
|
||||
transformRuntimeFunctionTypeToSuspendFunction(functionType, isReleaseCoroutines)?.let { return it }
|
||||
|
||||
// kotlin.suspend is still built with LV=1.2, thus it references old Continuation
|
||||
// And otherwise, once stdlib is compiled with 1.3 one may want to stay at LV=1.2
|
||||
if (c.containingDeclaration.safeAs<CallableDescriptor>()?.fqNameOrNull() == KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME) {
|
||||
transformRuntimeFunctionTypeToSuspendFunction(functionType, !isReleaseCoroutines)?.let { return it }
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun typeParameterTypeConstructor(typeParameterId: Int): TypeConstructor? =
|
||||
|
||||
Reference in New Issue
Block a user