[LL] Fix KtDynamicType deserialization

KT-63217
This commit is contained in:
Pavel Kirpichenkov
2023-11-07 16:23:03 +02:00
committed by Space Team
parent 171a6f1a87
commit 0736cb3fac
@@ -175,20 +175,17 @@ internal class StubBasedFirTypeDeserializer(
} }
private fun type(typeReference: KtTypeReference, attributes: ConeAttributes): ConeKotlinType { private fun type(typeReference: KtTypeReference, attributes: ConeAttributes): ConeKotlinType {
if (typeReference.typeElement?.unwrapNullability() is KtDynamicType) {
return ConeDynamicType.create(moduleData.session)
}
val userType = typeReference.typeElement as? KtUserType val userType = typeReference.typeElement as? KtUserType
val upperBoundType = (userType?.let { it.stub ?: loadStubByElement(it) } as? KotlinUserTypeStubImpl)?.upperBound val upperBoundType = (userType?.let { it.stub ?: loadStubByElement(it) } as? KotlinUserTypeStubImpl)?.upperBound
if (upperBoundType != null) { if (upperBoundType != null) {
val lowerBound = simpleType(typeReference, attributes) val lowerBound = simpleType(typeReference, attributes)
val upperBound = type(upperBoundType) val upperBound = type(upperBoundType)
val isDynamic = lowerBound == moduleData.session.builtinTypes.nothingType.coneType && return ConeFlexibleType(lowerBound!!, upperBound as ConeSimpleKotlinType)
upperBound == moduleData.session.builtinTypes.nullableAnyType.coneType
return if (isDynamic) {
ConeDynamicType.create(moduleData.session)
} else {
ConeFlexibleType(lowerBound!!, upperBound as ConeSimpleKotlinType)
}
} }
return simpleType(typeReference, attributes) ?: ConeErrorType(ConeSimpleDiagnostic("?!id:0", DiagnosticKind.DeserializationError)) return simpleType(typeReference, attributes) ?: ConeErrorType(ConeSimpleDiagnostic("?!id:0", DiagnosticKind.DeserializationError))