[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
origin: DELEGATED
receiverParameter: null
returnType: KtTypeErrorType:
returnType: KtUsualClassType:
annotationsList: []
type: ERROR CLASS: empty body
ownTypeArguments: []
type: kotlin/Int
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
@@ -2,7 +2,7 @@ fun noGeneric(): 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
@@ -10,7 +10,7 @@ fun <TT> withOwnGeneric(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
@@ -20,4 +20,4 @@ open fun hashCode(): kotlin.Int
open fun toString(): kotlin.String
constructor()
constructor()
@@ -93,9 +93,10 @@ KtFunctionSymbol:
name: withOuterGeneric
origin: SUBSTITUTION_OVERRIDE
receiverParameter: null
returnType: KtTypeErrorType:
returnType: KtUsualClassType:
annotationsList: []
type: ERROR CLASS: empty body
ownTypeArguments: []
type: kotlin/String
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: [
@@ -330,9 +331,10 @@ KtFunctionSymbol:
name: withOuterAndOwnGeneric
origin: SUBSTITUTION_OVERRIDE
receiverParameter: null
returnType: KtTypeErrorType:
returnType: KtUsualClassType:
annotationsList: []
type: ERROR CLASS: empty body
ownTypeArguments: []
type: kotlin/Long
symbolKind: CLASS_MEMBER
typeParameters: [
KtTypeParameterSymbol(TT)
@@ -614,4 +616,4 @@ KtConstructorSymbol:
valueParameters: []
visibility: Public
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.FirTowerDataContextCollector
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.ImplicitBodyResolveComputationSession
import org.jetbrains.kotlin.fir.scopes.fakeOverrideSubstitution
import org.jetbrains.kotlin.fir.visitors.transformSingle
internal object LLFirImplicitTypesLazyResolver : LLFirLazyResolver(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
@@ -91,10 +92,16 @@ internal class LLFirImplicitBodyTargetResolver(
-> {
// no implicit bodies here
}
is FirCallableDeclaration -> {
calculateLazyBodies(target)
target.transformSingle(transformer, ResolutionMode.ContextIndependent)
if (target.attributes.fakeOverrideSubstitution != null) {
transformer.returnTypeCalculator.fakeOverrideTypeCalculator.computeReturnType(target)
} else {
calculateLazyBodies(target)
target.transformSingle(transformer, ResolutionMode.ContextIndependent)
}
}
else -> throwUnexpectedFirElementError(target)
}
}
@@ -3,10 +3,10 @@ public final class A /* one.A*/ implements one.I {
private final one.I p;
@java.lang.Override()
public error.NonExistentClass foo();// foo()
public int bar();// bar()
@java.lang.Override()
public int bar();// bar()
public int foo();// foo()
public A(@org.jetbrains.annotations.NotNull() one.I);// .ctor(one.I)
}