From c7c83de528b7a34061c379add1a78d41bb6d1e35 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Sep 2023 15:49:46 +0300 Subject: [PATCH] [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 --- .../kotlin/fir/lazy/Fir2IrLazyClass.kt | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt index 9655578ddb1..ee8dfb4f50f 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt @@ -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) + } } } }