[FIR2IR] Don't create fake-overrides of static members like they are real ones

It's incorrect to create fake-overrides with `getOrCreateIrFunction/Property`
  call. FakeOverrideGenerator should be used instead. So this commit
  just changes the place which creates static f/o generated from

I failed to reproduce the corresponding failure in compiler tests, but
  without this change FP Kotlin test fails
This commit is contained in:
Dmitriy Novozhilov
2023-09-20 15:49:46 +03:00
committed by Space Team
parent bb093037c0
commit c7c83de528
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.lazy
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.containingClassLookupTag
import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.declarations.utils.*
import org.jetbrains.kotlin.fir.dispatchReceiverClassLookupTagOrNull import org.jetbrains.kotlin.fir.dispatchReceiverClassLookupTagOrNull
@@ -187,23 +188,26 @@ class Fir2IrLazyClass(
fun addDeclarationsFromScope(scope: FirContainingNamesAwareScope?) { fun addDeclarationsFromScope(scope: FirContainingNamesAwareScope?) {
if (scope == null) return if (scope == null) return
for (name in scope.getCallableNames()) { for (name in scope.getCallableNames()) {
scope.processFunctionsByName(name) { symbol -> scope.processFunctionsByName(name) l@{ symbol ->
if (symbol.isSubstitutionOrIntersectionOverride) return@processFunctionsByName when {
if (!shouldBuildStub(symbol.fir)) return@processFunctionsByName symbol.isSubstitutionOrIntersectionOverride -> {}
if (symbol.isStatic || symbol.dispatchReceiverClassLookupTagOrNull() == ownerLookupTag) { !shouldBuildStub(symbol.fir) -> {}
if (symbol.isAbstractMethodOfAny()) { symbol.containingClassLookupTag() != ownerLookupTag -> {}
return@processFunctionsByName symbol.isAbstractMethodOfAny() -> {}
else -> {
result += declarationStorage.getOrCreateIrFunction(symbol.fir, this, origin)
} }
result += declarationStorage.getOrCreateIrFunction(symbol.fir, this, origin)
} }
} }
scope.processPropertiesByName(name) { symbol -> scope.processPropertiesByName(name) l@{ symbol ->
if (symbol.isSubstitutionOrIntersectionOverride) return@processPropertiesByName when {
if (!shouldBuildStub(symbol.fir)) return@processPropertiesByName symbol.isSubstitutionOrIntersectionOverride -> {}
if (symbol is FirPropertySymbol && (symbol.isStatic || symbol.dispatchReceiverClassLookupTagOrNull() == ownerLookupTag)) { !shouldBuildStub(symbol.fir) -> {}
result.addIfNotNull( symbol.containingClassLookupTag() != ownerLookupTag -> {}
declarationStorage.getOrCreateIrProperty(symbol.fir, this, origin) symbol !is FirPropertySymbol -> {}
) else -> {
result += declarationStorage.getOrCreateIrProperty(symbol.fir, this, origin)
}
} }
} }
} }