[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.fir.backend.*
import org.jetbrains.kotlin.fir.containingClassLookupTag
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.*
import org.jetbrains.kotlin.fir.dispatchReceiverClassLookupTagOrNull
@@ -187,23 +188,26 @@ class Fir2IrLazyClass(
fun addDeclarationsFromScope(scope: FirContainingNamesAwareScope?) {
if (scope == null) return
for (name in scope.getCallableNames()) {
scope.processFunctionsByName(name) { symbol ->
if (symbol.isSubstitutionOrIntersectionOverride) return@processFunctionsByName
if (!shouldBuildStub(symbol.fir)) return@processFunctionsByName
if (symbol.isStatic || symbol.dispatchReceiverClassLookupTagOrNull() == ownerLookupTag) {
if (symbol.isAbstractMethodOfAny()) {
return@processFunctionsByName
scope.processFunctionsByName(name) l@{ symbol ->
when {
symbol.isSubstitutionOrIntersectionOverride -> {}
!shouldBuildStub(symbol.fir) -> {}
symbol.containingClassLookupTag() != ownerLookupTag -> {}
symbol.isAbstractMethodOfAny() -> {}
else -> {
result += declarationStorage.getOrCreateIrFunction(symbol.fir, this, origin)
}
result += declarationStorage.getOrCreateIrFunction(symbol.fir, this, origin)
}
}
scope.processPropertiesByName(name) { symbol ->
if (symbol.isSubstitutionOrIntersectionOverride) return@processPropertiesByName
if (!shouldBuildStub(symbol.fir)) return@processPropertiesByName
if (symbol is FirPropertySymbol && (symbol.isStatic || symbol.dispatchReceiverClassLookupTagOrNull() == ownerLookupTag)) {
result.addIfNotNull(
declarationStorage.getOrCreateIrProperty(symbol.fir, this, origin)
)
scope.processPropertiesByName(name) l@{ symbol ->
when {
symbol.isSubstitutionOrIntersectionOverride -> {}
!shouldBuildStub(symbol.fir) -> {}
symbol.containingClassLookupTag() != ownerLookupTag -> {}
symbol !is FirPropertySymbol -> {}
else -> {
result += declarationStorage.getOrCreateIrProperty(symbol.fir, this, origin)
}
}
}
}