[LL FIR] LLFirReturnTypeCalculatorWithJump: use declaration-site ScopeSession

We should use the declaration-site session to have stable
resolution order. The same scheme is applicable during
regular lazy resolution calls

^KT-63547
This commit is contained in:
Dmitrii Gridin
2023-12-19 18:13:03 +01:00
committed by Space Team
parent e3841a1728
commit 1538c125c3
3 changed files with 27 additions and 22 deletions
@@ -1,4 +1 @@
Diagnostics from elements:
for PSI element of type KtCallExpression at (26,5-36)
ARGUMENT_TYPE_MISMATCH text ranges: [(127,158)]
PSI: KtCallExpression at (26,5-36)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.collectDesignationWithFile
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.targets.asResolveTarget
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder.LLFirLockProvider
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.llFirSession
import org.jetbrains.kotlin.analysis.low.level.api.fir.transformers.LLFirImplicitBodyTargetResolver
import org.jetbrains.kotlin.analysis.low.level.api.fir.transformers.LLFirImplicitTypesLazyResolver
import org.jetbrains.kotlin.analysis.low.level.api.fir.transformers.LLImplicitBodyResolveComputationSession
@@ -33,11 +34,12 @@ internal class LLFirReturnTypeCalculatorWithJump(
declaration.lazyResolveToPhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE.previous)
val designation = declaration.collectDesignationWithFile().asResolveTarget()
val targetSession = designation.target.llFirSession
val resolver = LLFirImplicitBodyTargetResolver(
designation,
lockProvider = lockProvider,
session = declaration.moduleData.session,
scopeSession = scopeSession,
session = targetSession,
scopeSession = targetSession.getScopeSession(),
firResolveContextCollector = towerDataContextCollector,
llImplicitBodyResolveComputationSessionParameter = implicitBodyResolveComputationSession as LLImplicitBodyResolveComputationSession,
)
@@ -116,11 +116,13 @@ FILE: [ResolvedTo(IMPORTS)] usage.kt
public final [ResolvedTo(CONTRACTS)] fun usage(): <implicit> { LAZY_BLOCK }
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: [ResolvedTo(RAW_FIR)] dependency.kt
public? final? [ResolvedTo(RAW_FIR)] fun implicitType(): <implicit> { LAZY_BLOCK }
FILE: [ResolvedTo(IMPORTS)] dependency.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitType(): R|kotlin/Int| {
^implicitType Int(1)
}
FILE: [ResolvedTo(IMPORTS)] annotation.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitTypeFromAnotherModule(): R|kotlin/String| {
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitTypeFromAnotherModule(): R|kotlin/Int| {
^implicitTypeFromAnotherModule R|usage/implicitType|()
}
@@ -130,8 +132,8 @@ FILE: [ResolvedTo(IMPORTS)] dependency.kt
}
FILE: [ResolvedTo(IMPORTS)] usage.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun usage(): R|kotlin/String| {
^usage R|kotlin/run|<R|kotlin/String|>(<L> = [ResolvedTo(RAW_FIR)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/String| <inline=Inline, kind=EXACTLY_ONCE> {
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun usage(): R|kotlin/Int| {
^usage R|kotlin/run|<R|kotlin/Int|>(<L> = [ResolvedTo(RAW_FIR)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
R|usage/implicitType|()
^ R|usage/implicitTypeFromAnotherModule|()
}
@@ -139,11 +141,13 @@ FILE: [ResolvedTo(IMPORTS)] usage.kt
}
ANNOTATION_ARGUMENTS:
FILE: [ResolvedTo(RAW_FIR)] dependency.kt
public? final? [ResolvedTo(RAW_FIR)] fun implicitType(): <implicit> { LAZY_BLOCK }
FILE: [ResolvedTo(IMPORTS)] dependency.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitType(): R|kotlin/Int| {
^implicitType Int(1)
}
FILE: [ResolvedTo(IMPORTS)] annotation.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitTypeFromAnotherModule(): R|kotlin/String| {
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitTypeFromAnotherModule(): R|kotlin/Int| {
^implicitTypeFromAnotherModule R|usage/implicitType|()
}
@@ -153,8 +157,8 @@ FILE: [ResolvedTo(IMPORTS)] dependency.kt
}
FILE: [ResolvedTo(IMPORTS)] usage.kt
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] fun usage(): R|kotlin/String| {
^usage R|kotlin/run|<R|kotlin/String|>(<L> = [ResolvedTo(RAW_FIR)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/String| <inline=Inline, kind=EXACTLY_ONCE> {
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] fun usage(): R|kotlin/Int| {
^usage R|kotlin/run|<R|kotlin/Int|>(<L> = [ResolvedTo(RAW_FIR)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
R|usage/implicitType|()
^ R|usage/implicitTypeFromAnotherModule|()
}
@@ -162,11 +166,13 @@ FILE: [ResolvedTo(IMPORTS)] usage.kt
}
BODY_RESOLVE:
FILE: [ResolvedTo(RAW_FIR)] dependency.kt
public? final? [ResolvedTo(RAW_FIR)] fun implicitType(): <implicit> { LAZY_BLOCK }
FILE: [ResolvedTo(IMPORTS)] dependency.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitType(): R|kotlin/Int| {
^implicitType Int(1)
}
FILE: [ResolvedTo(IMPORTS)] annotation.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitTypeFromAnotherModule(): R|kotlin/String| {
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun implicitTypeFromAnotherModule(): R|kotlin/Int| {
^implicitTypeFromAnotherModule R|usage/implicitType|()
}
@@ -176,8 +182,8 @@ FILE: [ResolvedTo(IMPORTS)] dependency.kt
}
FILE: [ResolvedTo(IMPORTS)] usage.kt
public final [ResolvedTo(BODY_RESOLVE)] fun usage(): R|kotlin/String| {
^usage R|kotlin/run|<R|kotlin/String|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/String| <inline=Inline, kind=EXACTLY_ONCE> {
public final [ResolvedTo(BODY_RESOLVE)] fun usage(): R|kotlin/Int| {
^usage R|kotlin/run|<R|kotlin/Int|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
R|usage/implicitType|()
^ R|usage/implicitTypeFromAnotherModule|()
}
@@ -186,8 +192,8 @@ FILE: [ResolvedTo(IMPORTS)] usage.kt
FILE RAW TO BODY:
FILE: [ResolvedTo(BODY_RESOLVE)] usage.kt
public final [ResolvedTo(BODY_RESOLVE)] fun usage(): R|kotlin/String| {
^usage R|kotlin/run|<R|kotlin/String|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/String| <inline=Inline, kind=EXACTLY_ONCE> {
public final [ResolvedTo(BODY_RESOLVE)] fun usage(): R|kotlin/Int| {
^usage R|kotlin/run|<R|kotlin/Int|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<R>] run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
R|usage/implicitType|()
^ R|usage/implicitTypeFromAnotherModule|()
}