Copying kotlin-native fix
* commit 575cbf48c3
| Author: SvyatoslavScherbina <Svyatoslav.Scherbina@jetbrains.com>
| Date: Thu Mar 14 14:25:10 2019 +0300
|
| Optimize DescriptorReferenceDeserializer again (#2755)
to common ir deserializer.
This commit is contained in:
committed by
alexander-gorshenev
parent
826b9d935d
commit
0c8f0a433d
+14
-4
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|
||||||
abstract class DescriptorReferenceDeserializer(
|
abstract class DescriptorReferenceDeserializer(
|
||||||
val currentModule: ModuleDescriptor,
|
val currentModule: ModuleDescriptor,
|
||||||
@@ -30,13 +31,22 @@ abstract class DescriptorReferenceDeserializer(
|
|||||||
if (it == "<root>") FqName.ROOT else FqName(it)
|
if (it == "<root>") FqName.ROOT else FqName(it)
|
||||||
}// TODO: would we store an empty string in the protobuf?
|
}// TODO: would we store an empty string in the protobuf?
|
||||||
|
|
||||||
val contributedName = if (name.startsWith("<get-") || name.startsWith("<set-")) {
|
val memberScope = currentModule.getPackage(packageFqName).memberScope
|
||||||
|
return getContributedDescriptors(memberScope, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun getContributedDescriptors(memberScope: MemberScope, name: String): Collection<DeclarationDescriptor> {
|
||||||
|
val contributedNameString = if (name.startsWith("<get-") || name.startsWith("<set-")) {
|
||||||
|
|
||||||
name.substring(5, name.length - 1) // FIXME: rework serialization format.
|
name.substring(5, name.length - 1) // FIXME: rework serialization format.
|
||||||
} else {
|
} else {
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
return currentModule.getPackage(packageFqName).memberScope
|
val contributedName = Name.identifier(contributedNameString)
|
||||||
.getContributedDescriptors(nameFilter = { it.asString() == contributedName })
|
return memberScope.getContributedFunctions(contributedName, NoLookupLocation.FROM_BACKEND) +
|
||||||
|
memberScope.getContributedVariables(contributedName, NoLookupLocation.FROM_BACKEND) +
|
||||||
|
listOfNotNull(memberScope.getContributedClassifier(contributedName, NoLookupLocation.FROM_BACKEND))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class ClassMembers(val defaultConstructor: ClassConstructorDescriptor?,
|
protected class ClassMembers(val defaultConstructor: ClassConstructorDescriptor?,
|
||||||
@@ -87,7 +97,7 @@ abstract class DescriptorReferenceDeserializer(
|
|||||||
Pair(null, getContributedDescriptors(packageFqNameString, name))
|
Pair(null, getContributedDescriptors(packageFqNameString, name))
|
||||||
} else {
|
} else {
|
||||||
val clazz = currentModule.findClassAcrossModuleDependencies(ClassId(packageFqName, classFqName, false))!!
|
val clazz = currentModule.findClassAcrossModuleDependencies(ClassId(packageFqName, classFqName, false))!!
|
||||||
Pair(clazz, clazz.unsubstitutedMemberScope.getContributedDescriptors() + clazz.getConstructors())
|
Pair(clazz, getContributedDescriptors(clazz.unsubstitutedMemberScope, name) + clazz.getConstructors())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This is still native specific. Eliminate.
|
// TODO: This is still native specific. Eliminate.
|
||||||
|
|||||||
Reference in New Issue
Block a user