diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index 9744fdf2d65..6eda126338e 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -250,7 +250,7 @@ class DeserializedClassDescriptor( return c.components.platformDependentDeclarationFilter.isFunctionAvailable(this@DeserializedClassDescriptor, function) } - override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection) { + override fun computeNonDeclaredFunctions(name: Name, functions: MutableList) { val fromSupertypes = ArrayList() for (supertype in refinedSupertypes()) { fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)) @@ -260,7 +260,7 @@ class DeserializedClassDescriptor( generateFakeOverrides(name, fromSupertypes, functions) } - override fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection) { + override fun computeNonDeclaredProperties(name: Name, descriptors: MutableList) { val fromSupertypes = ArrayList() for (supertype in refinedSupertypes()) { fromSupertypes.addAll(supertype.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)) @@ -271,7 +271,7 @@ class DeserializedClassDescriptor( private fun generateFakeOverrides( name: Name, fromSupertypes: Collection, - result: MutableCollection + result: MutableList ) { val fromCurrent = ArrayList(result) c.components.kotlinTypeChecker.overridingUtil.generateOverridesInFunctionGroup( diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt index c7fbac741c4..5e11ec42680 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt @@ -39,9 +39,9 @@ import kotlin.collections.ArrayList abstract class DeserializedMemberScope protected constructor( protected val c: DeserializationContext, - functionList: Collection, - propertyList: Collection, - typeAliasList: Collection, + functionList: List, + propertyList: List, + typeAliasList: List, classNames: () -> Collection ) : MemberScopeImpl() { @@ -68,14 +68,26 @@ abstract class DeserializedMemberScope protected constructor( */ protected open fun isDeclaredFunctionAvailable(function: SimpleFunctionDescriptor): Boolean = true - protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection) { + /** + * This function has the next contract: + * + * * It can only add to the end of the [functions] list and shall not modify it otherwise (e.g. remove from it). + * * Before the call, [functions] should already contain all declared functions with the [name] name. + */ + protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableList) { } override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { return impl.getContributedFunctions(name, location) } - protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection) { + /** + * This function has the next contract: + * + * * It can only add to the end of the [descriptors] list and shall not modify it otherwise (e.g. remove from it). + * * Before the call, [descriptors] should already contain all declared properties with the [name] name. + */ + protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableList) { } private fun getTypeAliasByName(name: Name): TypeAliasDescriptor? { @@ -169,9 +181,9 @@ abstract class DeserializedMemberScope protected constructor( } private inner class OptimizedImplementation( - functionList: Collection, - propertyList: Collection, - typeAliasList: Collection + functionList: List, + propertyList: List, + typeAliasList: List ) : Implementation { private val functionProtosBytes = functionList.groupByName { it.name }.packToByteArray() @@ -225,7 +237,7 @@ abstract class DeserializedMemberScope protected constructor( bytesByName: Map, parser: Parser, factory: (M) -> D?, - computeNonDeclared: (MutableCollection) -> Unit + computeNonDeclared: (MutableList) -> Unit ): Collection = computeDescriptors( bytesByName[name]?.let { @@ -241,7 +253,7 @@ abstract class DeserializedMemberScope protected constructor( private inline fun computeDescriptors( protos: Collection, factory: (M) -> D?, - computeNonDeclared: (MutableCollection) -> Unit + computeNonDeclared: (MutableList) -> Unit ): Collection { val descriptors = protos.mapNotNullTo(ArrayList(protos.size), factory)