FIR2IR: minimize scope processing in fake override generation

This commit is contained in:
Jinseong Jeon
2021-03-02 14:50:18 -08:00
committed by Mikhail Glukhikh
parent c830aed946
commit 9934cfbb00
@@ -67,9 +67,21 @@ class FakeOverrideGenerator(
}
fun IrClass.getFakeOverrides(klass: FirClass<*>, realDeclarations: Collection<FirDeclaration>): List<IrDeclaration> {
val classLookupTag = klass.symbol.toLookupTag()
val realDeclarationNames = realDeclarations.mapNotNullTo(mutableSetOf()) {
val callableDeclaration = (it as? FirCallableMemberDeclaration<*>) ?: return@mapNotNullTo null
// We may need to create a new fake override or compute base symbols.
if (callableDeclaration.symbol.shouldHaveComputedBaseSymbolsForClass(classLookupTag) ||
callableDeclaration.allowsToHaveFakeOverrideIn(klass)
) null
// Otherwise, bail out early based on the name of the contributed member declaration
else callableDeclaration.symbol.callableId.callableName
}
val result = mutableListOf<IrDeclaration>()
val useSiteMemberScope = klass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = true)
val superTypesCallableNames = useSiteMemberScope.getCallableNames()
val superTypesCallableNames = useSiteMemberScope.getCallableNames().filter { it !in realDeclarationNames }
val realDeclarationSymbols = realDeclarations.filterIsInstance<FirSymbolOwner<*>>().mapTo(mutableSetOf(), FirSymbolOwner<*>::symbol)
for (name in superTypesCallableNames) {