Use declaration-site session in phased FIR instead of use-site session
This allows us to successfully find containing file for another module declaration
This commit is contained in:
@@ -37,7 +37,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.symbols.invoke
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||
import org.jetbrains.kotlin.fir.visitors.compose
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
@@ -439,7 +438,7 @@ class FirCallResolver(
|
||||
coneSymbol is FirBackingFieldSymbol -> FirBackingFieldReferenceImpl(source, null, coneSymbol)
|
||||
coneSymbol is FirVariableSymbol && (
|
||||
coneSymbol !is FirPropertySymbol ||
|
||||
(coneSymbol.phasedFir(session) as FirMemberDeclaration).typeParameters.isEmpty()
|
||||
(coneSymbol.phasedFir() as FirMemberDeclaration).typeParameters.isEmpty()
|
||||
) ->
|
||||
FirResolvedNamedReferenceImpl(source, name, coneSymbol)
|
||||
else -> FirNamedReferenceWithCandidate(source, name, candidate)
|
||||
|
||||
@@ -41,5 +41,5 @@ interface BodyResolveComponents : SessionHolder {
|
||||
val integerOperatorsTypeUpdater: IntegerOperatorsTypeUpdater
|
||||
|
||||
val <D> AbstractFirBasedSymbol<D>.phasedFir: D where D : FirDeclaration, D : FirSymbolOwner<D>
|
||||
get() = phasedFir(session, FirResolvePhase.DECLARATIONS)
|
||||
get() = phasedFir(FirResolvePhase.DECLARATIONS)
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ abstract class FirAbstractPhaseTransformer<D>(
|
||||
open val <D> AbstractFirBasedSymbol<D>.phasedFir: D where D : FirDeclaration, D : FirSymbolOwner<D>
|
||||
get() {
|
||||
val requiredPhase = transformerPhase.requiredToLaunch
|
||||
return phasedFir(session, requiredPhase)
|
||||
return phasedFir(requiredPhase)
|
||||
}
|
||||
|
||||
override fun transformFile(file: FirFile, data: D): CompositeTransformResult<FirFile> {
|
||||
|
||||
+2
-3
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
@@ -16,13 +15,13 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
|
||||
fun <D> AbstractFirBasedSymbol<D>.phasedFir(
|
||||
session: FirSession,
|
||||
requiredPhase: FirResolvePhase = FirResolvePhase.DECLARATIONS
|
||||
): D where D : FirDeclaration, D : FirSymbolOwner<D> {
|
||||
val result = this.fir
|
||||
val availablePhase = result.resolvePhase
|
||||
if (availablePhase < requiredPhase) {
|
||||
val provider = FirProvider.getInstance(session)
|
||||
// NB: we should use session from symbol here, not transformer session (important for IDE)
|
||||
val provider = FirProvider.getInstance(fir.session)
|
||||
val containingFile = when (this) {
|
||||
is FirCallableSymbol<*> -> provider.getFirCallableContainerFile(this)
|
||||
is FirClassLikeSymbol<*> -> provider.getFirClassifierContainerFile(this)
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb
|
||||
final override val <D> AbstractFirBasedSymbol<D>.phasedFir: D where D : FirDeclaration, D : FirSymbolOwner<D>
|
||||
get() {
|
||||
val requiredPhase = transformerPhase.requiredToLaunch
|
||||
return phasedFir(session, requiredPhase)
|
||||
return phasedFir(requiredPhase)
|
||||
}
|
||||
|
||||
protected inline fun <T> withScopeCleanup(scopes: MutableList<*>, crossinline l: () -> T): T {
|
||||
|
||||
Reference in New Issue
Block a user