[LL FIR] support lazy resolve for fake override declarations

^KT-58727 Fixed
This commit is contained in:
Dmitrii Gridin
2023-05-16 20:32:38 +02:00
committed by Space Team
parent 4472e1ae4e
commit ae1622d059
6 changed files with 26 additions and 16 deletions
@@ -1,3 +1,3 @@
open fun foo(): ERROR(empty body) open fun foo(): kotlin.Int
open fun bar(): kotlin.Int open fun bar(): kotlin.Int
@@ -17,9 +17,10 @@ KtFunctionSymbol:
name: foo name: foo
origin: DELEGATED origin: DELEGATED
receiverParameter: null receiverParameter: null
returnType: KtTypeErrorType: returnType: KtUsualClassType:
annotationsList: [] annotationsList: []
type: ERROR CLASS: empty body ownTypeArguments: []
type: kotlin/Int
symbolKind: CLASS_MEMBER symbolKind: CLASS_MEMBER
typeParameters: [] typeParameters: []
valueParameters: [] valueParameters: []
@@ -2,7 +2,7 @@ fun noGeneric(): kotlin.Int
fun noGenericWithExplicitType(): kotlin.Int fun noGenericWithExplicitType(): kotlin.Int
fun withOuterGeneric(t: test.Foo): ERROR(empty body) fun withOuterGeneric(t: test.Foo): kotlin.String
fun withOuterGenericWithExplicitType(t: test.Foo): kotlin.String fun withOuterGenericWithExplicitType(t: test.Foo): kotlin.String
@@ -10,7 +10,7 @@ fun <TT> withOwnGeneric(tt: TT): kotlin.Boolean
fun <TT> withOwnGenericWithExplicitType(tt: TT): kotlin.Boolean fun <TT> withOwnGenericWithExplicitType(tt: TT): kotlin.Boolean
fun <TT> withOuterAndOwnGeneric(t: test.Foo, tt: TT): ERROR(empty body) fun <TT> withOuterAndOwnGeneric(t: test.Foo, tt: TT): kotlin.Long
fun <TT> withOuterAndOwnGenericWithExplicitType(t: test.Foo, tt: TT): kotlin.Long fun <TT> withOuterAndOwnGenericWithExplicitType(t: test.Foo, tt: TT): kotlin.Long
@@ -20,4 +20,4 @@ open fun hashCode(): kotlin.Int
open fun toString(): kotlin.String open fun toString(): kotlin.String
constructor() constructor()
@@ -93,9 +93,10 @@ KtFunctionSymbol:
name: withOuterGeneric name: withOuterGeneric
origin: SUBSTITUTION_OVERRIDE origin: SUBSTITUTION_OVERRIDE
receiverParameter: null receiverParameter: null
returnType: KtTypeErrorType: returnType: KtUsualClassType:
annotationsList: [] annotationsList: []
type: ERROR CLASS: empty body ownTypeArguments: []
type: kotlin/String
symbolKind: CLASS_MEMBER symbolKind: CLASS_MEMBER
typeParameters: [] typeParameters: []
valueParameters: [ valueParameters: [
@@ -330,9 +331,10 @@ KtFunctionSymbol:
name: withOuterAndOwnGeneric name: withOuterAndOwnGeneric
origin: SUBSTITUTION_OVERRIDE origin: SUBSTITUTION_OVERRIDE
receiverParameter: null receiverParameter: null
returnType: KtTypeErrorType: returnType: KtUsualClassType:
annotationsList: [] annotationsList: []
type: ERROR CLASS: empty body ownTypeArguments: []
type: kotlin/Long
symbolKind: CLASS_MEMBER symbolKind: CLASS_MEMBER
typeParameters: [ typeParameters: [
KtTypeParameterSymbol(TT) KtTypeParameterSymbol(TT)
@@ -614,4 +616,4 @@ KtConstructorSymbol:
valueParameters: [] valueParameters: []
visibility: Public visibility: Public
getContainingModule: KtSourceModule "Sources of main" getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null deprecationStatus: null
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirTowerDataContextCollector import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirTowerDataContextCollector
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.ImplicitBodyResolveComputationSession import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.ImplicitBodyResolveComputationSession
import org.jetbrains.kotlin.fir.scopes.fakeOverrideSubstitution
import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.fir.visitors.transformSingle
internal object LLFirImplicitTypesLazyResolver : LLFirLazyResolver(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) { internal object LLFirImplicitTypesLazyResolver : LLFirLazyResolver(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
@@ -91,10 +92,16 @@ internal class LLFirImplicitBodyTargetResolver(
-> { -> {
// no implicit bodies here // no implicit bodies here
} }
is FirCallableDeclaration -> { is FirCallableDeclaration -> {
calculateLazyBodies(target) if (target.attributes.fakeOverrideSubstitution != null) {
target.transformSingle(transformer, ResolutionMode.ContextIndependent) transformer.returnTypeCalculator.fakeOverrideTypeCalculator.computeReturnType(target)
} else {
calculateLazyBodies(target)
target.transformSingle(transformer, ResolutionMode.ContextIndependent)
}
} }
else -> throwUnexpectedFirElementError(target) else -> throwUnexpectedFirElementError(target)
} }
} }
@@ -3,10 +3,10 @@ public final class A /* one.A*/ implements one.I {
private final one.I p; private final one.I p;
@java.lang.Override() @java.lang.Override()
public error.NonExistentClass foo();// foo() public int bar();// bar()
@java.lang.Override() @java.lang.Override()
public int bar();// bar() public int foo();// foo()
public A(@org.jetbrains.annotations.NotNull() one.I);// .ctor(one.I) public A(@org.jetbrains.annotations.NotNull() one.I);// .ctor(one.I)
} }