From 8a90032e9351fabcd025809b233a44a47d57750c Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Tue, 27 Feb 2024 12:24:13 +0100 Subject: [PATCH] [FIR] Refactor deferred computation of callable copy return types Rename some classes for clarity and move the implementations to the use sites. --- .../lazyResolve/delegateWithImplicitType.txt | 6 +- ...gateWithImplicitTypeInDifferentModules.txt | 6 +- .../delegateWithImplicitTypeScript.txt | 6 +- .../implicitSubstitutionOverrideProperty.txt | 6 +- ...icitSubstitutionOverridePropertyScript.txt | 6 +- .../propertyDelegateWithImplicitType.txt | 6 +- ...propertyDelegateWithImplicitTypeScript.txt | 6 +- ...onFakeOverrideFunctionWithImplicitType.txt | 6 +- ...OverrideFunctionWithImplicitTypeScript.txt | 6 +- ...bstitutionFakeOverrideWithImplicitType.txt | 6 +- ...akeOverrideWithImplicitTypeAndReceiver.txt | 6 +- ...rrideWithImplicitTypeAndReceiverScript.txt | 6 +- ...tionFakeOverrideWithImplicitTypeScript.txt | 6 +- ...plicitTypeInsideAnonymousObject.before.txt | 2 +- ...TypeInsideAnonymousObjectScript.before.txt | 2 +- ...AnonymousObjectWithSubstitution.before.txt | 16 +-- ...ousObjectWithSubstitutionScript.before.txt | 16 +-- ...rideWithImplicitTypeInsideClass.before.txt | 2 +- ...thImplicitTypeInsideClassScript.before.txt | 2 +- ...TypeInsideClassWithSubstitution.before.txt | 16 +-- ...sideClassWithSubstitutionScript.before.txt | 16 +-- ...plicitTypeInsideAnonymousObject.before.txt | 16 +-- ...TypeInsideAnonymousObjectScript.before.txt | 16 +-- ...plicitTypeInsideAnonymousObject.before.txt | 2 +- ...TypeInsideAnonymousObjectScript.before.txt | 2 +- ...rideWithImplicitTypeInsideClass.before.txt | 2 +- ...thImplicitTypeInsideClassScript.before.txt | 2 +- .../delegateWithImplicitType.lazyResolve.txt | 6 +- ...gateWithImplicitTypeScript.lazyResolve.txt | 6 +- ...ithImplicitTypeUnavailable.lazyResolve.txt | 6 +- ...licitTypeUnavailableScript.lazyResolve.txt | 6 +- .../implicitFunction.lazyResolve.txt | 6 +- .../implicitFunctionScript.lazyResolve.txt | 6 +- ...mplicitFunctionUnavailable.lazyResolve.txt | 6 +- ...tFunctionUnavailableScript.lazyResolve.txt | 6 +- .../implicitProperty.lazyResolve.txt | 6 +- ...mplicitPropertyAndReceiver.lazyResolve.txt | 6 +- ...tPropertyAndReceiverScript.lazyResolve.txt | 6 +- .../implicitPropertyScript.lazyResolve.txt | 6 +- ...mplicitPropertyUnavailable.lazyResolve.txt | 6 +- ...tPropertyUnavailableScript.lazyResolve.txt | 6 +- .../fir/scopes/CallableCopyTypeCalculator.kt | 101 +++++++++--------- .../scopes/impl/FirClassSubstitutionScope.kt | 26 ++++- .../scopes/impl/FirFakeOverrideGenerator.kt | 39 ++++--- .../impl/FirTypeIntersectionScopeContext.kt | 44 +++++--- .../body/resolve/FirImplicitBodyResolve.kt | 4 +- 46 files changed, 257 insertions(+), 231 deletions(-) diff --git a/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitType.txt b/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitType.txt index 62d4270685a..813cec091e7 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitType.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitType.txt @@ -1,5 +1,5 @@ STATUS: -TARGET: public open override [ResolvedTo(STATUS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open override [ResolvedTo(STATUS)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): FILE: [ResolvedTo(IMPORTS)] delegateWithImplicitType.kt public final [ResolvedTo(STATUS)] [DelegateFieldsMapKey={0=FirFieldSymbol /Aaa.$$delegate_0}] class Aaa : R|Interface| { @@ -16,7 +16,7 @@ FILE: [ResolvedTo(IMPORTS)] delegateWithImplicitType.kt } EXPECT_ACTUAL_MATCHING: -TARGET: public open override [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open override [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): FILE: [ResolvedTo(IMPORTS)] delegateWithImplicitType.kt public final [ResolvedTo(STATUS)] [DelegateFieldsMapKey={0=FirFieldSymbol /Aaa.$$delegate_0}] class Aaa : R|Interface| { @@ -33,7 +33,7 @@ FILE: [ResolvedTo(IMPORTS)] delegateWithImplicitType.kt } CONTRACTS: -TARGET: public open override [ResolvedTo(CONTRACTS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open override [ResolvedTo(CONTRACTS)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): FILE: [ResolvedTo(IMPORTS)] delegateWithImplicitType.kt public final [ResolvedTo(STATUS)] [DelegateFieldsMapKey={0=FirFieldSymbol /Aaa.$$delegate_0}] class Aaa : R|Interface| { diff --git a/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeInDifferentModules.txt b/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeInDifferentModules.txt index f5e0376e25c..c6bd3042332 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeInDifferentModules.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeInDifferentModules.txt @@ -1,5 +1,5 @@ STATUS: -TARGET: public open override [ResolvedTo(STATUS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open override [ResolvedTo(STATUS)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): FILE: [ResolvedTo(IMPORTS)] Interface.kt public abstract [ResolvedTo(STATUS)] interface Interface : R|kotlin/Any| { @@ -18,7 +18,7 @@ FILE: [ResolvedTo(IMPORTS)] usage.kt } EXPECT_ACTUAL_MATCHING: -TARGET: public open override [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open override [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): FILE: [ResolvedTo(IMPORTS)] Interface.kt public abstract [ResolvedTo(STATUS)] interface Interface : R|kotlin/Any| { @@ -37,7 +37,7 @@ FILE: [ResolvedTo(IMPORTS)] usage.kt } CONTRACTS: -TARGET: public open override [ResolvedTo(CONTRACTS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open override [ResolvedTo(CONTRACTS)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): FILE: [ResolvedTo(IMPORTS)] Interface.kt public abstract [ResolvedTo(STATUS)] interface Interface : R|kotlin/Any| { diff --git a/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeScript.txt b/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeScript.txt index fcf19da999e..a5ee11023bd 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeScript.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitTypeScript.txt @@ -1,5 +1,5 @@ STATUS: -TARGET: public open override [ResolvedTo(STATUS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open override [ResolvedTo(STATUS)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): FILE: [ResolvedTo(IMPORTS)] delegateWithImplicitTypeScript.kts context(