[FIR] resolve type annotations on implicit return type of local property
This still doesn't work for unresolved delegate (see analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/localDelegatedPropertyWithPropagatedType.out_of_src_roots.txt) ^KT-63042
This commit is contained in:
committed by
Space Team
parent
143f86cc1c
commit
dbaf4a2d5e
+5
-5
@@ -3,7 +3,7 @@ FIR element: FirPropertyImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>|by R|kotlin/lazy|<R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<T>] lazy@fun <anonymous>(): R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>| <inline=NoInline> {
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>|by R|kotlin/lazy|<R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<T>] lazy@fun <anonymous>(): R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>| <inline=NoInline> {
|
||||
^ R|foo/explicitType|()
|
||||
}
|
||||
)
|
||||
@@ -21,13 +21,13 @@ FILE: [ResolvedTo(IMPORTS)] localDelegatedPropertyWithPropagatedType.kt
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=Anno] get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public final [ResolvedTo(CONTRACTS)] fun explicitType(): R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>| {
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val constant: R|kotlin/Int| = Int(0)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public final [ResolvedTo(CONTRACTS)] fun explicitType(): R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>| {
|
||||
^explicitType IntegerLiteral(0)
|
||||
}
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun resolveMe(): R|kotlin/Unit| {
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>|by R|kotlin/lazy|<R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<T>] lazy@fun <anonymous>(): R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>| <inline=NoInline> {
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>|by R|kotlin/lazy|<R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>|>(<L> = [ResolvedTo(BODY_RESOLVE)] [MatchingParameterFunctionTypeKey=kotlin/Function0<T>] lazy@fun <anonymous>(): R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>| <inline=NoInline> {
|
||||
^ R|foo/explicitType|()
|
||||
}
|
||||
)
|
||||
|
||||
+5
-5
@@ -3,7 +3,7 @@ FIR element: FirPropertyImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>| = R|foo/explicitType|()
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>| = R|foo/explicitType|()
|
||||
|
||||
FIR FILE:
|
||||
FILE: [ResolvedTo(IMPORTS)] localPropertyWithPropagatedType.kt
|
||||
@@ -18,13 +18,13 @@ FILE: [ResolvedTo(IMPORTS)] localPropertyWithPropagatedType.kt
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=Anno] get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public final [ResolvedTo(CONTRACTS)] fun explicitType(): R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>| {
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val constant: R|kotlin/Int| = Int(0)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public final [ResolvedTo(CONTRACTS)] fun explicitType(): R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>| {
|
||||
^explicitType IntegerLiteral(0)
|
||||
}
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun resolveMe(): R|kotlin/Unit| {
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(<strcat>(String(return type: ), constant#)) kotlin/collections/List<@R|foo/Anno|(<strcat>(String(nested return type: ), constant#)) kotlin/collections/Collection<@R|foo/Anno|(<strcat>(String(nested nested return type: ), constant#)) kotlin/String>>| = R|foo/explicitType|()
|
||||
@R|foo/Anno|[Types](position = <strcat>(String(property ), R|foo/secondConstant|)) [ResolvedTo(BODY_RESOLVE)] lval localProperty: R|@R|foo/Anno|(position = <strcat>(String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = <strcat>(String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = <strcat>(String(nested nested return type: ), R|foo/constant|)) kotlin/String>>| = R|foo/explicitType|()
|
||||
}
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val secondConstant: R|kotlin/String| = String(str)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/String|
|
||||
+5
-1
@@ -523,7 +523,11 @@ open class FirDeclarationsResolveTransformer(
|
||||
variable.transformBackingField(transformer, withExpectedType(variable.returnTypeRef))
|
||||
variable.transformAccessors()
|
||||
}
|
||||
variable.transformOtherChildren(transformer, ResolutionMode.ContextIndependent)
|
||||
|
||||
// We need this return type transformation to resolve annotations from an implicit type
|
||||
variable.transformReturnTypeRef(transformer, ResolutionMode.ContextIndependent)
|
||||
.transformOtherChildren(transformer, ResolutionMode.ContextIndependent)
|
||||
|
||||
context.storeVariable(variable, session)
|
||||
dataFlowAnalyzer.exitLocalVariableDeclaration(variable, hadExplicitType)
|
||||
return variable
|
||||
|
||||
Reference in New Issue
Block a user