From 535de7bdc863be9cef0e0fd81aeb06b59b36b034 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 14 Sep 2020 16:22:55 +0300 Subject: [PATCH] [FIR] Cleanup code of FirTypeDeserializer.kt --- .../deserialization/FirTypeDeserializer.kt | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt index 5b8b514cf98..dc8fea32df0 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt @@ -102,7 +102,6 @@ class FirTypeDeserializer( val lowerBound = simpleType(proto, attributes) val upperBound = simpleType(proto.flexibleUpperBound(typeTable)!!, attributes) return ConeFlexibleType(lowerBound!!, upperBound!!) - //c.components.flexibleTypeDeserializer.create(proto, id, lowerBound, upperBound) } return simpleType(proto, attributes) ?: ConeKotlinErrorType(ConeSimpleDiagnostic("?!id:0", DiagnosticKind.DeserializationError)) @@ -125,7 +124,6 @@ class FirTypeDeserializer( (fir as? FirTypeParameterRefsOwner)?.typeParameters?.map { it.symbol }.orEmpty() fun simpleType(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeLookupTagBasedType? { - val constructor = typeSymbol(proto) ?: return null if (constructor is ConeTypeParameterLookupTag) return ConeTypeParameterTypeImpl(constructor, isNullable = proto.nullable) if (constructor !is ConeClassLikeLookupTag) return null @@ -134,21 +132,16 @@ class FirTypeDeserializer( argumentList + outerType(typeTable)?.collectAllArguments().orEmpty() val arguments = proto.collectAllArguments().map(this::typeArgument).toTypedArray() - val simpleType = if (Flags.SUSPEND_TYPE.get(proto.flags)) { createSuspendFunctionType(constructor, arguments, isNullable = proto.nullable, attributes) } else { ConeClassLikeTypeImpl(constructor, arguments, isNullable = proto.nullable, attributes) } - val abbreviatedTypeProto = proto.abbreviatedType(typeTable) ?: return simpleType - return simpleType(abbreviatedTypeProto, attributes) - } private fun createSuspendFunctionTypeForBasicCase( - //annotations: Annotations, TODO?, functionTypeConstructor: ConeClassLikeLookupTag, arguments: Array, isNullable: Boolean, @@ -160,13 +153,9 @@ class FirTypeDeserializer( return true } - val returnType = arguments.lastOrNull() val continuationType = arguments.getOrNull(arguments.lastIndex - 1) as? ConeClassLikeType ?: return null - if (!continuationType.isContinuation()) return ConeClassLikeTypeImpl(functionTypeConstructor, arguments, isNullable, attributes) - val suspendReturnType = continuationType.typeArguments.single() as ConeKotlinTypeProjection - val valueParameters = arguments.dropLast(2) val kind = FunctionClassKind.SuspendFunction @@ -178,7 +167,6 @@ class FirTypeDeserializer( } private fun createSuspendFunctionType( - //annotations: Annotations, TODO? functionTypeConstructor: ConeClassLikeLookupTag, arguments: Array, isNullable: Boolean, @@ -186,8 +174,7 @@ class FirTypeDeserializer( ): ConeClassLikeType { val result = when (functionTypeConstructor.toSymbol(session)!!.firUnsafe().typeParameters.size - arguments.size) { - 0 -> createSuspendFunctionTypeForBasicCase(/* annotations, */ functionTypeConstructor, arguments, isNullable, attributes) -// This case for types written by eap compiler 1.1 + 0 -> createSuspendFunctionTypeForBasicCase(functionTypeConstructor, arguments, isNullable, attributes) 1 -> { val arity = arguments.size - 1 if (arity >= 0) { @@ -213,7 +200,6 @@ class FirTypeDeserializer( } private fun typeSymbol(proto: ProtoBuf.Type): ConeClassifierLookupTag? { - return when { proto.hasClassName() -> computeClassifier(proto.className) proto.hasTypeAliasName() -> computeClassifier(proto.typeAliasName) @@ -235,10 +221,7 @@ class FirTypeDeserializer( val variance = ProtoEnumFlags.variance(typeArgumentProto.projection) val type = typeArgumentProto.type(typeTable) ?: return ConeKotlinErrorType(ConeSimpleDiagnostic("No type recorded", DiagnosticKind.DeserializationError)) - - // TODO: check that here we don't have any attributes val coneType = type(type, ConeAttributes.Empty) return coneType.toTypeProjection(variance) } - }