Drop TypeAliasDeserializer

Currently it's only used for local type aliases, while code in
'deserializeTypeAlias' works properly only for nested or top-level type
aliases.

Also it seems that serialization of types based on local type aliases
doesn't work now anyway (see KT-13692)
This commit is contained in:
Denis Zharkov
2016-09-01 11:09:42 +03:00
parent 86c1dbe7b5
commit 6a22d75dd7
3 changed files with 2 additions and 42 deletions
@@ -1,38 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.serialization.deserialization
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.ClassId
class TypeAliasDeserializer(private val components: DeserializationComponents) {
fun deserializeTypeAlias(typeAliasId: ClassId): TypeAliasDescriptor? {
val parentScope = if (typeAliasId.isNestedClass) {
val outerClass = components.classDeserializer.deserializeClass(typeAliasId.outerClassId) ?: return null
outerClass.unsubstitutedMemberScope
}
else {
val packageFragment = components.packageFragmentProvider.getPackageFragments(typeAliasId.packageFqName).single()
packageFragment.getMemberScope()
}
return parentScope.getContributedClassifier(typeAliasId.shortClassName, NoLookupLocation.FROM_DESERIALIZATION) as? TypeAliasDescriptor
}
}
@@ -147,7 +147,8 @@ class TypeDeserializer(
private fun computeTypeAliasDescriptor(fqNameIndex: Int): ClassifierDescriptor? {
val id = c.nameResolver.getClassId(fqNameIndex)
return if (id.isLocal) {
c.components.deserializeTypeAlias(id)
// TODO: support deserialization of local type aliases (see KT-13692)
return null
}
else {
c.components.moduleDescriptor.findTypeAliasAcrossModuleDependencies(id)
@@ -41,7 +41,6 @@ class DeserializationComponents(
val platformDependentDeclarationFilter: PlatformDependentDeclarationFilter = PlatformDependentDeclarationFilter.All
) {
val classDeserializer: ClassDeserializer = ClassDeserializer(this)
val typeAliasDeserializer: TypeAliasDeserializer = TypeAliasDeserializer(this)
fun deserializeClass(classId: ClassId): ClassDescriptor? = classDeserializer.deserializeClass(classId)
@@ -53,8 +52,6 @@ class DeserializationComponents(
): DeserializationContext =
DeserializationContext(this, nameResolver, descriptor, typeTable, containerSource,
parentTypeDeserializer = null, typeParameters = listOf())
fun deserializeTypeAlias(typeAliasId: ClassId): TypeAliasDescriptor? = typeAliasDeserializer.deserializeTypeAlias(typeAliasId)
}