[K/N] Drop merging forward and real declaration in deserializer

^KT-59643
This commit is contained in:
Pavel Kunyavskiy
2023-07-11 14:05:34 +02:00
committed by Space Team
parent e4c2fa1080
commit d797505f06
15 changed files with 19 additions and 126 deletions
@@ -1,17 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.descriptors.deserialization
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.types.SimpleType
interface PlatformDependentTypeTransformer {
fun transformPlatformType(classId: ClassId, computedType: SimpleType): SimpleType
object None : PlatformDependentTypeTransformer {
override fun transformPlatformType(classId: ClassId, computedType: SimpleType): SimpleType = computedType
}
}
@@ -237,31 +237,6 @@ private class SimpleTypeImpl(
}
}
// Note: a hack to support class descriptor overwriting in case of K/N forward declaration replacement and other such cases
class SupposititiousSimpleType(private val realType: SimpleType, val overwrittenClass: ClassId) : SimpleType() {
private fun maybeWrap(newType: SimpleType): SupposititiousSimpleType {
return if (newType === realType) this
else SupposititiousSimpleType(newType, overwrittenClass)
}
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
maybeWrap(realType.replaceAttributes(newAttributes))
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType =
maybeWrap(realType.makeNullableAsSpecified(newNullability))
@TypeRefinement
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): SimpleType =
maybeWrap(realType.refine(kotlinTypeRefiner))
override val constructor: TypeConstructor = realType.constructor
override val arguments: List<TypeProjection> = realType.arguments
override val isMarkedNullable: Boolean = realType.isMarkedNullable
override val memberScope: MemberScope = realType.memberScope
override val attributes: TypeAttributes get() = realType.attributes
}
abstract class DelegatingSimpleTypeImpl(override val delegate: SimpleType) : DelegatingSimpleType() {
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
if (newAttributes !== attributes)
@@ -137,11 +137,6 @@ class TypeDeserializer(
simpleType.withAbbreviation(simpleType(it, expandTypeAliases = false))
} ?: simpleType
if (proto.hasClassName()) {
val classId = c.nameResolver.getClassId(proto.className)
return c.components.platformDependentTypeTransformer.transformPlatformType(classId, computedType)
}
return computedType
}
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.deserialization.AdditionalClassPartsProvider
import org.jetbrains.kotlin.descriptors.deserialization.ClassDescriptorFactory
import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentDeclarationFilter
import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentTypeTransformer
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.*
@@ -54,7 +53,6 @@ class DeserializationComponents(
val extensionRegistryLite: ExtensionRegistryLite,
val kotlinTypeChecker: NewKotlinTypeChecker = NewKotlinTypeChecker.Default,
val samConversionResolver: SamConversionResolver,
val platformDependentTypeTransformer: PlatformDependentTypeTransformer = PlatformDependentTypeTransformer.None,
val typeAttributeTranslators: List<TypeAttributeTranslator> = listOf(DefaultTypeAttributeTranslator),
val enumEntriesDeserializationSupport: EnumEntriesDeserializationSupport = EnumEntriesDeserializationSupport.Default,
) {