diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDelegatedMemberScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDelegatedMemberScope.kt index 96697551c94..ad1ca7b1a74 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDelegatedMemberScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDelegatedMemberScope.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -50,10 +50,12 @@ class FirDelegatedMemberScope( result.forEach(processor) } - private fun buildScope(delegateField: FirField): FirTypeScope? { - return delegateField.returnTypeRef.coneType - .scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing, requiredPhase = null) - } + private fun buildScope(delegateField: FirField): FirTypeScope? = delegateField.symbol.resolvedReturnType.scope( + session, + scopeSession, + FakeOverrideTypeCalculator.DoNothing, + requiredPhase = null, + ) private fun collectFunctionsFromSpecificField( delegateField: FirField, @@ -136,19 +138,22 @@ class FirDelegatedMemberScope( return@processor } + if (propertySymbol.modality == Modality.FINAL || propertySymbol.visibility == Visibilities.Private) { + return@processor + } + val original = propertySymbol.fir - - if (original.modality == Modality.FINAL || original.visibility == Visibilities.Private) { - return@processor + var isOverriddenProperty = false + declaredMemberScope.processPropertiesByName(name) { + if (it is FirPropertySymbol && overrideChecker.isOverriddenProperty(it.fir, original)) { + isOverriddenProperty = true + } } - if (declaredMemberScope.getProperties(name) - .any { it is FirPropertySymbol && overrideChecker.isOverriddenProperty(it.fir, original) } - ) { + if (isOverriddenProperty) { return@processor } - result.firstOrNull { overrideChecker.isOverriddenProperty(it.fir, original) }?.let { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt index db7c2aaa257..2a0bfcee7ae 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt @@ -1,4 +1,3 @@ -// IGNORE_REVERSED_RESOLVE // See KT-15566 // NI_EXPECTED_FILE diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.kt index 22594dd5cdc..a2c58cd474c 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.kt @@ -1,4 +1,3 @@ -// IGNORE_REVERSED_RESOLVE // See KT-15566 // NI_EXPECTED_FILE