Minor. Extract function in TypeDeserializer

This commit is contained in:
Denis Zharkov
2018-06-20 20:13:24 +03:00
parent 9deb9473d2
commit 3d3d21cb93
@@ -132,11 +132,7 @@ class TypeDeserializer(
isReleaseCoroutines: Boolean isReleaseCoroutines: Boolean
): SimpleType { ): SimpleType {
val result = when (functionTypeConstructor.parameters.size - arguments.size) { val result = when (functionTypeConstructor.parameters.size - arguments.size) {
0 -> { 0 -> createSuspendFunctionTypeForBasicCase(annotations, functionTypeConstructor, arguments, nullable, isReleaseCoroutines)
val functionType = KotlinTypeFactory.simpleType(annotations, functionTypeConstructor, arguments, nullable)
functionType.takeIf { it.isFunctionType }
?.let { funType -> transformRuntimeFunctionTypeToSuspendFunction(funType, isReleaseCoroutines) }
}
// This case for types written by eap compiler 1.1 // This case for types written by eap compiler 1.1
1 -> { 1 -> {
val arity = arguments.size - 1 val arity = arguments.size - 1
@@ -159,6 +155,18 @@ class TypeDeserializer(
) )
} }
private fun createSuspendFunctionTypeForBasicCase(
annotations: Annotations,
functionTypeConstructor: TypeConstructor,
arguments: List<TypeProjection>,
nullable: Boolean,
isReleaseCoroutines: Boolean
): SimpleType? {
val functionType = KotlinTypeFactory.simpleType(annotations, functionTypeConstructor, arguments, nullable)
if (!functionType.isFunctionType) return null
return transformRuntimeFunctionTypeToSuspendFunction(functionType, isReleaseCoroutines)
}
private fun typeParameterTypeConstructor(typeParameterId: Int): TypeConstructor? = private fun typeParameterTypeConstructor(typeParameterId: Int): TypeConstructor? =
typeParameterDescriptors.get(typeParameterId)?.typeConstructor ?: parent?.typeParameterTypeConstructor(typeParameterId) typeParameterDescriptors.get(typeParameterId)?.typeConstructor ?: parent?.typeParameterTypeConstructor(typeParameterId)