Fix incremental compilation for calls to inner classes from supertypes

The problem became actual after 8c2baf0704
This commit is contained in:
Denis Zharkov
2020-06-30 18:17:17 +03:00
committed by Ilya Muradyan
parent 6b81cc8b77
commit 3ce980fd88
16 changed files with 81 additions and 1 deletions
@@ -126,6 +126,7 @@ class MetadataPackageFragment(
override fun hasClass(name: Name): Boolean = hasTopLevelClass(name)
override fun definitelyDoesNotContainName(name: Name) = false
override fun getClassifierNames(): Set<Name>? = null
override fun getNonDeclaredClassifierNames(): Set<Name>? = null
})
return ChainedMemberScope.create("Metadata scope", scopes)
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.types.SimpleType
import org.jetbrains.kotlin.types.TypeConstructor
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
import org.jetbrains.kotlin.types.refinement.TypeRefinement
import org.jetbrains.kotlin.utils.addToStdlib.flatMapToNullable
import java.util.*
class DeserializedClassDescriptor(
@@ -307,6 +308,12 @@ class DeserializedClassDescriptor(
}
}
override fun getNonDeclaredClassifierNames(): Set<Name>? {
return classDescriptor.typeConstructor.supertypes.flatMapToNullable(LinkedHashSet()) {
it.memberScope.getClassifierNames()
}
}
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
recordLookup(name, location)
classDescriptor.enumEntries?.findEnumEntry(name)?.let { return it }
@@ -81,9 +81,15 @@ abstract class DeserializedMemberScope protected constructor(
internal val classNames by c.storageManager.createLazyValue { classNames().toSet() }
private val classifierNamesLazy = c.storageManager.createNullableLazyValue {
val nonDeclaredNames = getNonDeclaredClassifierNames() ?: return@createNullableLazyValue null
this.classNames + typeAliasNames + nonDeclaredNames
}
override fun getFunctionNames() = functionNamesLazy
override fun getVariableNames() = variableNamesLazy
override fun getClassifierNames(): Set<Name>? = classNames + typeAliasNames
override fun getClassifierNames(): Set<Name>? = classifierNamesLazy()
override fun definitelyDoesNotContainName(name: Name): Boolean {
return name !in functionNamesLazy && name !in variableNamesLazy && name !in classNames && name !in typeAliasNames
@@ -256,6 +262,7 @@ abstract class DeserializedMemberScope protected constructor(
protected abstract fun getNonDeclaredFunctionNames(): Set<Name>
protected abstract fun getNonDeclaredVariableNames(): Set<Name>
protected abstract fun getNonDeclaredClassifierNames(): Set<Name>?
protected abstract fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
@@ -69,6 +69,7 @@ open class DeserializedPackageMemberScope(
override fun getNonDeclaredFunctionNames(): Set<Name> = emptySet()
override fun getNonDeclaredVariableNames(): Set<Name> = emptySet()
override fun getNonDeclaredClassifierNames(): Set<Name>? = emptySet()
override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
// Do nothing