FIR: Fix serialization of non-delegated members in FirDelegatedMemberScope

This commit is contained in:
Denis.Zharkov
2021-06-30 14:39:40 +03:00
committed by TeamCityServer
parent 3671b14e5b
commit a3f64f65f2
2 changed files with 30 additions and 4 deletions
@@ -33,7 +33,7 @@ class FirDelegatedMemberScope(
private val containingClass: FirClass,
private val declaredMemberScope: FirScope,
private val delegateFields: List<FirField>,
) : FirScope() {
) : FirScope(), FirContainingNamesAwareScope {
private val dispatchReceiverType = containingClass.defaultType()
private val overrideChecker = FirStandardOverrideChecker(session)
@@ -171,6 +171,31 @@ class FirDelegatedMemberScope(
result += delegatedSymbol
}
}
@OptIn(ExperimentalStdlibApi::class)
private val callableNamesLazy: Set<Name> by lazy(LazyThreadSafetyMode.PUBLICATION) {
buildSet {
addAll(declaredMemberScope.getContainingCallableNamesIfPresent())
delegateFields.flatMapTo(this) {
buildScope(it)?.getCallableNames() ?: emptySet()
}
}
}
@OptIn(ExperimentalStdlibApi::class)
private val classifierNamesLazy: Set<Name> by lazy(LazyThreadSafetyMode.PUBLICATION) {
buildSet {
addAll(declaredMemberScope.getContainingClassifierNamesIfPresent())
delegateFields.flatMapTo(this) {
buildScope(it)?.getClassifierNames() ?: emptySet()
}
}
}
override fun getCallableNames(): Set<Name> = callableNamesLazy
override fun getClassifierNames(): Set<Name> = classifierNamesLazy
}
private object MultipleDelegatesWithTheSameSignatureKey : FirDeclarationDataKey()