From 1238f081b7f9bad10e8a052dfd870b87c5e86f02 Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Thu, 18 Jan 2024 16:54:28 +0100 Subject: [PATCH] [FIR] Defer computation of intersection override return type if overridden has implicit return type #KT-59921 --- .../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 ++--- ...mplicitTypeInsideAnonymousObject.after.txt | 2 +- ...plicitTypeInsideAnonymousObject.before.txt | 16 ++--- ...tTypeInsideAnonymousObjectScript.after.txt | 2 +- ...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 +- .../kotlin/fir/scopes/jvm/JvmMappedScope.kt | 2 +- .../fir/scopes/CallableCopyTypeCalculator.kt | 67 ++++++++++++++----- .../scopes/impl/FirFakeOverrideGenerator.kt | 51 +++++++------- .../impl/FirTypeIntersectionScopeContext.kt | 54 ++++++++++----- 47 files changed, 252 insertions(+), 200 deletions(-) diff --git a/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitType.txt b/analysis/low-level-api-fir/testData/lazyResolve/delegateWithImplicitType.txt index 917410d4ff1..4a9b1472451 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 [ResolvedTo(STATUS)] [CallableCopySubstitutionKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open [ResolvedTo(STATUS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(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 [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [CallableCopySubstitutionKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open [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(): 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 [ResolvedTo(CONTRACTS)] [CallableCopySubstitutionKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open [ResolvedTo(CONTRACTS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(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 19c9434e2d6..0f5d8cfb70e 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 [ResolvedTo(STATUS)] [CallableCopySubstitutionKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open [ResolvedTo(STATUS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(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 [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [CallableCopySubstitutionKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open [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(): 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 [ResolvedTo(CONTRACTS)] [CallableCopySubstitutionKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open [ResolvedTo(CONTRACTS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(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 10db25bd27e..b638f2f842c 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 [ResolvedTo(STATUS)] [CallableCopySubstitutionKey=CallableCopySubstitution(substitutor=Empty, baseSymbol=FirNamedFunctionSymbol /Interface.implicitType), DelegatedWrapperDataKey=[wrapped=FirNamedFunctionSymbol /Interface.implicitType, containingClass=Aaa, delegateField=FirFieldSymbol /Aaa.$$delegate_0] fun implicitType(): +TARGET: public open [ResolvedTo(STATUS)] [CallableCopyDeferredReturnTypeCalculationKey=CallableCopySubstitution(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(