[LL FIR] LLFirContractsLazyResolver: avoid transformation for delegated properties

Delegated properties can't have any contracts.
This change also should improve memory consumption because we will
less frequently calculate bodies.

^KT-55750
This commit is contained in:
Dmitrii Gridin
2023-09-20 14:03:36 +02:00
committed by Space Team
parent 3e9e66493f
commit 2962482d75
10 changed files with 29 additions and 47 deletions
@@ -63,7 +63,12 @@ private class LLFirContractsTargetResolver(
}
is FirConstructor -> resolve(target, ContractStateKeepers.CONSTRUCTOR)
is FirProperty -> resolve(target, ContractStateKeepers.PROPERTY)
is FirProperty -> {
// Property with delegate can't have any contracts
if (target.delegate == null) {
resolve(target, ContractStateKeepers.PROPERTY)
}
}
is FirRegularClass,
is FirTypeAlias,
is FirVariable,
@@ -153,10 +153,7 @@ FILE: [ResolvedTo(IMPORTS)] compilerRequiredAnnotationsOnPropertyDelegate.kt
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
}
field:@PROPERTY_DELEGATE_FIELD:R|kotlin/Deprecated|[Types](String(delegate)) @PROPERTY_DELEGATE_FIELD:R|Anno|[Types](String(delegate)) public final [ResolvedTo(CONTRACTS)] val memberProperty: <implicit>by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
String(42)
}
)
field:@PROPERTY_DELEGATE_FIELD:R|kotlin/Deprecated|[Types](String(delegate)) @PROPERTY_DELEGATE_FIELD:R|Anno|[Types](String(delegate)) public final [ResolvedTo(CONTRACTS)] val memberProperty: <implicit>by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] get(): <implicit> {
^ D|/memberProperty|.getValue#(Null(null), ::R|/memberProperty|)
}
@@ -153,10 +153,7 @@ FILE: [ResolvedTo(IMPORTS)] compilerRequiredAnnotationsOnPropertyDelegate.kt
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
}
field:@PROPERTY_DELEGATE_FIELD:R|kotlin/Deprecated|[Types](String(delegate)) @PROPERTY_DELEGATE_FIELD:R|Anno|[Types](String(delegate)) public final [ResolvedTo(CONTRACTS)] val memberProperty: <implicit>by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
String(42)
}
)
field:@PROPERTY_DELEGATE_FIELD:R|kotlin/Deprecated|[Types](String(delegate)) @PROPERTY_DELEGATE_FIELD:R|Anno|[Types](String(delegate)) public final [ResolvedTo(CONTRACTS)] val memberProperty: <implicit>by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] get(): <implicit> {
^ D|/memberProperty|.getValue#(Null(null), ::R|/memberProperty|)
}
@@ -212,10 +212,7 @@ FILE: [ResolvedTo(IMPORTS)] compilerRequiredAnnotationsOnPropertyDelegateScript.
}
field:@PROPERTY_DELEGATE_FIELD:R|kotlin/Deprecated|[Types](String(delegate)) @PROPERTY_DELEGATE_FIELD:R|Anno|[Types](String(delegate)) public final [ResolvedTo(CONTRACTS)] val memberProperty: <implicit>by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
String(42)
}
)
field:@PROPERTY_DELEGATE_FIELD:R|kotlin/Deprecated|[Types](String(delegate)) @PROPERTY_DELEGATE_FIELD:R|Anno|[Types](String(delegate)) public final [ResolvedTo(CONTRACTS)] val memberProperty: <implicit>by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] get(): <implicit> {
^ D|/memberProperty|.getValue#(Null(null), ::R|/memberProperty|)
}
@@ -319,3 +316,4 @@ FILE: [ResolvedTo(BODY_RESOLVE)] compilerRequiredAnnotationsOnPropertyDelegateSc
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/String| {
^ D|/memberProperty|.R|kotlin/getValue|<R|kotlin/String|>(Null(null), ::R|/memberProperty|)
}
@@ -386,7 +386,7 @@ FILE: [ResolvedTo(IMPORTS)] delegates.kt
}
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>|
public final [ResolvedTo(CONTRACTS)] val valueWithExplicitType: R|kotlin/Int|by delegate#
public final [ResolvedTo(CONTRACTS)] val valueWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int| {
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
}
@@ -394,7 +394,7 @@ FILE: [ResolvedTo(IMPORTS)] delegates.kt
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int| {
^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
}
public final [ResolvedTo(CONTRACTS)] var variableWithExplicitType: R|kotlin/Int|by delegate#
public final [ResolvedTo(CONTRACTS)] var variableWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int| {
^ D|/variableWithExplicitType|.getValue#(Null(null), ::R|/variableWithExplicitType|)
}
@@ -525,7 +525,7 @@ FILE: [ResolvedTo(IMPORTS)] delegatesScript.kts
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>|
public final [ResolvedTo(CONTRACTS)] val valueWithExplicitType: R|kotlin/Int|by delegate#
public final [ResolvedTo(CONTRACTS)] val valueWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int| {
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
}
@@ -535,7 +535,7 @@ FILE: [ResolvedTo(IMPORTS)] delegatesScript.kts
^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
}
public final [ResolvedTo(CONTRACTS)] var variableWithExplicitType: R|kotlin/Int|by delegate#
public final [ResolvedTo(CONTRACTS)] var variableWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int| {
^ D|/variableWithExplicitType|.getValue#(Null(null), ::R|/variableWithExplicitType|)
}
@@ -609,3 +609,4 @@ FILE: [ResolvedTo(BODY_RESOLVE)] delegatesScript.kts
public [ResolvedTo(BODY_RESOLVE)] set([ResolvedTo(BODY_RESOLVE)] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
^ D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithImplicitType|, R|<local>/variableWithImplicitType|)
}
@@ -271,10 +271,7 @@ FILE: [ResolvedTo(IMPORTS)] lazyProperty.kt
LAZY_super<R|kotlin/Any|>
}
public final [ResolvedTo(CONTRACTS)] val resolveMe: R|kotlin/String|by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
materialize#()
}
)
public final [ResolvedTo(CONTRACTS)] val resolveMe: R|kotlin/String|by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] [ContainingClassKey=Test] get(): R|kotlin/String| {
^ this@R|/Test|.D|/Test.resolveMe|.getValue#(this@R|/Test|, ::R|/Test.resolveMe|)
}
@@ -302,10 +299,7 @@ FILE: [ResolvedTo(IMPORTS)] lazyProperty.kt
LAZY_super<R|kotlin/Any|>
}
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val resolveMe: R|kotlin/String|by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
materialize#()
}
)
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val resolveMe: R|kotlin/String|by LAZY_EXPRESSION
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] [ContainingClassKey=Test] get(): R|kotlin/String| {
^ this@R|/Test|.D|/Test.resolveMe|.getValue#(this@R|/Test|, ::R|/Test.resolveMe|)
}
@@ -333,10 +327,7 @@ FILE: [ResolvedTo(IMPORTS)] lazyProperty.kt
LAZY_super<R|kotlin/Any|>
}
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val resolveMe: R|kotlin/String|by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
materialize#()
}
)
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val resolveMe: R|kotlin/String|by LAZY_EXPRESSION
public [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] [ContainingClassKey=Test] get(): R|kotlin/String| {
^ this@R|/Test|.D|/Test.resolveMe|.getValue#(this@R|/Test|, ::R|/Test.resolveMe|)
}
@@ -360,10 +360,7 @@ FILE: [ResolvedTo(IMPORTS)] lazyPropertyScript.kts
LAZY_super<R|kotlin/Any|>
}
public final [ResolvedTo(CONTRACTS)] val resolveMe: R|kotlin/String|by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
materialize#()
}
)
public final [ResolvedTo(CONTRACTS)] val resolveMe: R|kotlin/String|by LAZY_EXPRESSION
public [ResolvedTo(CONTRACTS)] [ContainingClassKey=Test] get(): R|kotlin/String| {
^ this@R|/Test|.D|/Test.resolveMe|.getValue#(this@R|/Test|, ::R|/Test.resolveMe|)
}
@@ -400,10 +397,7 @@ FILE: [ResolvedTo(IMPORTS)] lazyPropertyScript.kts
LAZY_super<R|kotlin/Any|>
}
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val resolveMe: R|kotlin/String|by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
materialize#()
}
)
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val resolveMe: R|kotlin/String|by LAZY_EXPRESSION
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] [ContainingClassKey=Test] get(): R|kotlin/String| {
^ this@R|/Test|.D|/Test.resolveMe|.getValue#(this@R|/Test|, ::R|/Test.resolveMe|)
}
@@ -440,10 +434,7 @@ FILE: [ResolvedTo(IMPORTS)] lazyPropertyScript.kts
LAZY_super<R|kotlin/Any|>
}
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val resolveMe: R|kotlin/String|by lazy#(<L> = [ResolvedTo(RAW_FIR)] lazy@fun <implicit>.<anonymous>(): <implicit> <inline=Unknown> {
materialize#()
}
)
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val resolveMe: R|kotlin/String|by LAZY_EXPRESSION
public [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] [ContainingClassKey=Test] get(): R|kotlin/String| {
^ this@R|/Test|.D|/Test.resolveMe|.getValue#(this@R|/Test|, ::R|/Test.resolveMe|)
}
@@ -541,3 +532,4 @@ FILE: [ResolvedTo(BODY_RESOLVE)] lazyPropertyScript.kts
}
}
@@ -135,7 +135,7 @@ FILE: [ResolvedTo(IMPORTS)] getterWithDelegation.kt
CONTRACTS:
FILE: [ResolvedTo(IMPORTS)] getterWithDelegation.kt
public final [ResolvedTo(CONTRACTS)] val one: R|kotlin/Int|by Prp#()
public final [ResolvedTo(CONTRACTS)] val one: R|kotlin/Int|by LAZY_EXPRESSION
@R|kotlin/Deprecated|[Types](String(reason)) public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int| {
^ D|/one|.getValue#(Null(null), ::R|/one|)
}
@@ -150,7 +150,7 @@ FILE: [ResolvedTo(IMPORTS)] getterWithDelegation.kt
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] getterWithDelegation.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val one: R|kotlin/Int|by Prp#()
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val one: R|kotlin/Int|by LAZY_EXPRESSION
@R|kotlin/Deprecated|[Types](String(reason)) public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int| {
^ D|/one|.getValue#(Null(null), ::R|/one|)
}
@@ -165,7 +165,7 @@ FILE: [ResolvedTo(IMPORTS)] getterWithDelegation.kt
ANNOTATIONS_ARGUMENTS_MAPPING:
FILE: [ResolvedTo(IMPORTS)] getterWithDelegation.kt
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val one: R|kotlin/Int|by Prp#()
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val one: R|kotlin/Int|by LAZY_EXPRESSION
@R|kotlin/Deprecated|[Types](message = String(reason)) public [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] get(): R|kotlin/Int| {
^ D|/one|.getValue#(Null(null), ::R|/one|)
}
@@ -193,7 +193,7 @@ FILE: [ResolvedTo(IMPORTS)] getterWithDelegationScript.kts
SCRIPT: [ResolvedTo(TYPES)] <script-getterWithDelegationScript.kts>
[ResolvedTo(RAW_FIR)] lval args: R|kotlin/Array<kotlin/String>|
public final [ResolvedTo(CONTRACTS)] val one: R|kotlin/Int|by Prp#()
public final [ResolvedTo(CONTRACTS)] val one: R|kotlin/Int|by LAZY_EXPRESSION
@R|kotlin/Deprecated|[Types](String(reason)) public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int| {
^ D|/one|.getValue#(Null(null), ::R|/one|)
}
@@ -214,7 +214,7 @@ FILE: [ResolvedTo(IMPORTS)] getterWithDelegationScript.kts
SCRIPT: [ResolvedTo(TYPES)] <script-getterWithDelegationScript.kts>
[ResolvedTo(RAW_FIR)] lval args: R|kotlin/Array<kotlin/String>|
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val one: R|kotlin/Int|by Prp#()
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val one: R|kotlin/Int|by LAZY_EXPRESSION
@R|kotlin/Deprecated|[Types](String(reason)) public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int| {
^ D|/one|.getValue#(Null(null), ::R|/one|)
}
@@ -235,7 +235,7 @@ FILE: [ResolvedTo(IMPORTS)] getterWithDelegationScript.kts
SCRIPT: [ResolvedTo(TYPES)] <script-getterWithDelegationScript.kts>
[ResolvedTo(RAW_FIR)] lval args: R|kotlin/Array<kotlin/String>|
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val one: R|kotlin/Int|by Prp#()
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] val one: R|kotlin/Int|by LAZY_EXPRESSION
@R|kotlin/Deprecated|[Types](message = String(reason)) public [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] get(): R|kotlin/Int| {
^ D|/one|.getValue#(Null(null), ::R|/one|)
}
@@ -294,3 +294,4 @@ FILE: [ResolvedTo(BODY_RESOLVE)] getterWithDelegationScript.kts
}
}