[FIR] pre-resolve some scope callables before creating a scope
In a lot of cases, when we want to process the declaration in scope, it should be resolved to at least TYPES phase. To avoid doing it manually in all our variety of scopes, we do it when the scope it created. It was implicitly working manually before as lazy resolve did a lot of extra work on resolving a declaration it was not supposed to resolve. Now it's not the case, and we have to explicitly resolve all the declarations we need. ^KT-56543 Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
23e40693a3
commit
706ff6b61f
+1
-1
@@ -30,7 +30,7 @@ class AllPropertiesConstructorMetadataProvider(session: FirSession) : FirDeclara
|
||||
|
||||
override fun provideDeclarationsForClass(klass: FirClass, scopeSession: ScopeSession): List<FirDeclaration> {
|
||||
if (!session.predicateBasedProvider.matches(PREDICATE, klass)) return emptyList()
|
||||
val scope = klass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false)
|
||||
val scope = klass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false, memberRequiredPhase = null)
|
||||
val properties = scope.getCallableNames()
|
||||
.flatMap { scope.getProperties(it) }
|
||||
.sortedBy { it.containingClassLookupTag() == klass.symbol.toLookupTag() }
|
||||
|
||||
+13
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
@@ -13,18 +13,25 @@ import org.jetbrains.kotlin.fir.analysis.checkers.getContainingDeclarationSymbol
|
||||
import org.jetbrains.kotlin.fir.containingClassForStaticMemberAttr
|
||||
import org.jetbrains.kotlin.fir.copy
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunctionCopy
|
||||
import org.jetbrains.kotlin.fir.declarations.origin
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
|
||||
import org.jetbrains.kotlin.fir.extensions.*
|
||||
import org.jetbrains.kotlin.fir.plugin.*
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.*
|
||||
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
||||
import org.jetbrains.kotlin.fir.scopes.getFunctions
|
||||
import org.jetbrains.kotlin.fir.scopes.getProperties
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||
import org.jetbrains.kotlin.fir.scopes.scopeForSupertype
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeProjection
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.fir.types.constructClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.constructType
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -140,7 +147,7 @@ class SerializationFirResolveExtension(session: FirSession) : FirDeclarationGene
|
||||
val scopes = lookupSuperTypes(
|
||||
owner, lookupInterfaces = true, deep = false, useSiteSession = session
|
||||
).mapNotNull { useSiteSuperType ->
|
||||
useSiteSuperType.scopeForSupertype(session, scopeSession, owner.fir)
|
||||
useSiteSuperType.scopeForSupertype(session, scopeSession, owner.fir, memberRequiredPhase = null)
|
||||
}
|
||||
val targets = scopes.flatMap { extractor(it) }
|
||||
return targets.singleOrNull() ?: error("Multiple overrides found for ${callableId.callableName}")
|
||||
|
||||
Reference in New Issue
Block a user