[FIR IDE] Ensure resolve to CONTRACTS phase in ReturnTypeCalculator

If we want to analyse some function's call, we need to know about its
contracts, otherwise resolving the following code would be broken.
Computing return type of function is a prerequisite to using it in any
sensible way, so it's the best place to resolve it to CONTRACTS

KT-50733
This commit is contained in:
Roman Golyshev
2022-05-27 13:30:19 +04:00
committed by Space
parent e14ac2a062
commit 166c771e1b
59 changed files with 260 additions and 64 deletions
@@ -217,9 +217,12 @@ FILE: classMembers.kt
public final [STATUS] val x: R|kotlin/Int| = LAZY_EXPRESSION
[STATUS] [ContainingClassKey=A] public get(): R|kotlin/Int| { LAZY_BLOCK }
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK }
public final [CONTRACTS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
}
public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| { LAZY_BLOCK }
public final [CONTRACTS] fun functionWithLazyBody(): R|kotlin/String| {
^functionWithLazyBody String(42)
}
}
@@ -341,8 +341,9 @@ FILE: delegates.kt
R|/variableWithExplicitType| = Int(10)
R|/variableWithImplicitType| = Int(10)
}
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK }
public final [STATUS] val delegate: R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>| = object : R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>| {
public final [CONTRACTS] fun receive([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| {
}
public final [CONTRACTS] val delegate: R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>| = object : R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>| {
private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
@@ -357,19 +358,19 @@ FILE: delegates.kt
}
[BODY_RESOLVE] public get(): R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>|
public final [STATUS] val valueWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION
[STATUS] public get(): <implicit> {
public final [CONTRACTS] val valueWithExplicitType: R|kotlin/Int|by delegate#
[CONTRACTS] public get(): <implicit> {
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
}
public final [IMPLICIT_TYPES_BODY_RESOLVE] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
}
public final [STATUS] var variableWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION
[STATUS] public get(): <implicit> {
public final [CONTRACTS] var variableWithExplicitType: R|kotlin/Int|by delegate#
[CONTRACTS] public get(): <implicit> {
^ D|/variableWithExplicitType|.getValue#(Null(null), ::R|/variableWithExplicitType|)
}
[STATUS] public set([RAW_FIR] <set-?>: <implicit>): R|kotlin/Unit| {
[CONTRACTS] public set([RAW_FIR] <set-?>: <implicit>): R|kotlin/Unit| {
D|/variableWithExplicitType|.setValue#(Null(null), ::R|/variableWithExplicitType|, R|<local>/variableWithExplicitType|)
}
public final [IMPLICIT_TYPES_BODY_RESOLVE] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
@@ -87,9 +87,12 @@ FILE: propertyWithGetter.kt
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
R|/receive|(R|/withGetter|)
}
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK }
public final [STATUS] val withGetter: R|kotlin/Int|
[STATUS] public get(): R|kotlin/Int| { LAZY_BLOCK }
public final [CONTRACTS] fun receive([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| {
}
public final [CONTRACTS] val withGetter: R|kotlin/Int|
[CONTRACTS] public get(): R|kotlin/Int| {
^ IntegerLiteral(42)
}
FILE RAW TO BODY:
FILE: propertyWithGetter.kt
@@ -102,10 +102,15 @@ FILE: propertyWithGetterAndSetter.kt
R|/receive|(R|/withGetterAndSetter|)
R|/withGetterAndSetter| = Int(123)
}
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK }
public final [STATUS] var withGetterAndSetter: R|kotlin/Int| = LAZY_EXPRESSION
[STATUS] public get(): R|kotlin/Int| { LAZY_BLOCK }
[STATUS] public set([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK }
public final [CONTRACTS] fun receive([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| {
}
public final [CONTRACTS] var withGetterAndSetter: R|kotlin/Int| = IntegerLiteral(42)
[CONTRACTS] public get(): R|kotlin/Int| {
^ field#
}
[CONTRACTS] public set([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| {
field# = value#
}
FILE RAW TO BODY:
FILE: propertyWithGetterAndSetter.kt
@@ -76,7 +76,7 @@ FILE: propertyWithInitializer.kt
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
<Unresolved name: receive>#(R|/property|)
}
public final [STATUS] val property: R|kotlin/Int| = LAZY_EXPRESSION
public final [CONTRACTS] val property: R|kotlin/Int| = IntegerLiteral(10)
[BODY_RESOLVE] public get(): R|kotlin/Int|
FILE RAW TO BODY:
@@ -142,7 +142,8 @@ FILE: secondaryConstructor.kt
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
R|/receive|(R|/A.A|(Int(42)))
}
public final [STATUS] fun receive([RAW_FIR] value: R|A|): R|kotlin/Unit| { LAZY_BLOCK }
public final [CONTRACTS] fun receive([RAW_FIR] value: R|A|): R|kotlin/Unit| {
}
public final [STATUS] class A : R|kotlin/Any| {
public [STATUS] [ContainingClassKey=A] constructor([RAW_FIR] x: R|kotlin/Int|): R|A| {
super<R|kotlin/Any|>()
@@ -76,8 +76,11 @@ FILE: topLevelFunctions.kt
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
R|/receive|(R|/functionWithLazyBody|())
}
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK }
public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| { LAZY_BLOCK }
public final [CONTRACTS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
}
public final [CONTRACTS] fun functionWithLazyBody(): R|kotlin/String| {
^functionWithLazyBody String(42)
}
FILE RAW TO BODY:
FILE: topLevelFunctions.kt
@@ -76,8 +76,11 @@ FILE: topLevelFunctionsWithExpressionBodyAndExplicitType.kt
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
R|/receive|(R|/functionWithLazyBody|())
}
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK }
public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| { LAZY_BLOCK }
public final [CONTRACTS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
}
public final [CONTRACTS] fun functionWithLazyBody(): R|kotlin/String| {
^functionWithLazyBody String(42)
}
FILE RAW TO BODY:
FILE: topLevelFunctionsWithExpressionBodyAndExplicitType.kt
@@ -76,7 +76,8 @@ FILE: topLevelFunctionsWithImplicitType.kt
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
R|/receive|(R|/functionWithLazyBody|())
}
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK }
public final [CONTRACTS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
}
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun functionWithLazyBody(): R|kotlin/String| {
^functionWithLazyBody String(42)
}