[FIR] add memberRequiredPhase to declaredMemberScope

^KT-56551
This commit is contained in:
Dmitrii Gridin
2023-05-15 12:17:07 +02:00
committed by Space Team
parent 01a94624f5
commit 5b3f617378
12 changed files with 105 additions and 60 deletions
@@ -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.
*/
@@ -219,7 +219,7 @@ object FirImportsChecker : FirFileChecker() {
predicate: (FirNamedFunctionSymbol) -> Boolean
): Boolean {
var result = false
context.session.declaredMemberScope(this).processFunctionsByName(name) { sym ->
context.session.declaredMemberScope(this, memberRequiredPhase = null).processFunctionsByName(name) { sym ->
if (!result) {
result = predicate(sym)
}
@@ -237,13 +237,13 @@ object FirImportsChecker : FirFileChecker() {
private fun FirRegularClassSymbol.getImportStatusOfCallableMembers(context: CheckerContext, name: Name): ImportStatus {
return if (classKind.isSingleton) {
// Use declaredMemberScope first because it's faster, and it's relatively rare to import members declared from super types.
val scopes = listOf(context.session.declaredMemberScope(this), unsubstitutedScope(context))
val scopes = listOf(context.session.declaredMemberScope(this, memberRequiredPhase = null), unsubstitutedScope(context))
getImportStatus(scopes, context, name) { true }
} else {
val scopes = listOfNotNull(
// We first try resolution with declaredMemberScope because it's faster and typically imported members are not from
// super types.
context.session.declaredMemberScope(this),
context.session.declaredMemberScope(this, memberRequiredPhase = null),
// Next, we try static scope, which can provide static (Java) members from super classes. Note that it's not available
// for pure Kotlin classes.