[API Usage] Refine supertypes when getting content of member scope

This commit is contained in:
Dmitry Savvinov
2019-07-10 15:41:29 +03:00
parent 1d61d75225
commit 9047ddfc2f
2 changed files with 17 additions and 7 deletions
@@ -217,6 +217,11 @@ class DeserializedClassDescriptor(
computeDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
}
private val refinedSupertypes = c.storageManager.createLazyValue {
@UseExperimental(TypeRefinement::class)
kotlinTypeRefiner.refineSupertypes(classDescriptor)
}
override fun getContributedDescriptors(
kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> = allDescriptors()
@@ -233,7 +238,7 @@ class DeserializedClassDescriptor(
override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<SimpleFunctionDescriptor>) {
val fromSupertypes = ArrayList<SimpleFunctionDescriptor>()
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
for (supertype in refinedSupertypes()) {
fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED))
}
@@ -247,7 +252,7 @@ class DeserializedClassDescriptor(
override fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
val fromSupertypes = ArrayList<PropertyDescriptor>()
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
for (supertype in refinedSupertypes()) {
fromSupertypes.addAll(supertype.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED))
}
generateFakeOverrides(name, fromSupertypes, descriptors)