From ded234074db88e8328245f606b0966a046b45fa7 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 25 Feb 2021 18:45:25 +0100 Subject: [PATCH] FIR: render value parameter/lambda/accessor resolve phase if RenderMode.renderDeclarationResolvePhase is enabled --- .../org/jetbrains/kotlin/fir/FirRenderer.kt | 3 +++ .../testdata/lazyResolve/classMembers.txt | 4 ++-- .../testdata/lazyResolve/delegates.txt | 20 +++++++++---------- .../lazyResolve/propertyWithGetter.txt | 4 ++-- .../propertyWithGetterAndSetter.txt | 6 +++--- .../lazyResolve/propertyWithInitializer.txt | 2 +- .../lazyResolve/secondaryConstructor.txt | 4 ++-- .../lazyResolve/topLevelFunctions.txt | 2 +- ...tionsWithExpressionBodyAndExplicitType.txt | 2 +- .../topLevelFunctionsWithImplicitType.txt | 2 +- idea/testData/fir/lazyResolve/elvis/main.txt | 4 ++-- idea/testData/fir/lazyResolve/inInit/main.txt | 2 +- .../fir/lazyResolve/inSecondary/main.txt | 2 +- idea/testData/fir/lazyResolve/simple/main.txt | 2 +- .../lazyResolve/simpleProperty/myProperty.txt | 2 +- 15 files changed, 32 insertions(+), 29 deletions(-) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index f8d3b667678..d14e48726ef 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -511,6 +511,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM } override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor) { + propertyAccessor.renderPhaseIfNeeded() propertyAccessor.annotations.renderAnnotations() print(propertyAccessor.visibility.asString() + " ") print(if (propertyAccessor.isGetter) "get" else "set") @@ -522,6 +523,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM } override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction) { + anonymousFunction.renderPhaseIfNeeded() anonymousFunction.annotations.renderAnnotations() val label = anonymousFunction.label if (label != null) { @@ -620,6 +622,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM } override fun visitValueParameter(valueParameter: FirValueParameter) { + valueParameter.renderPhaseIfNeeded() valueParameter.annotations.renderAnnotations() if (valueParameter.isCrossinline) { print("crossinline ") diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/classMembers.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/classMembers.txt index bcdf205e668..ba17a81cc45 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/classMembers.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/classMembers.txt @@ -9,9 +9,9 @@ FILE: classMembers.kt } public final [CONTRACTS] val x: R|kotlin/Int| = LAZY_EXPRESSION - public get(): R|kotlin/Int| { LAZY_BLOCK } + [STATUS] public get(): R|kotlin/Int| { LAZY_BLOCK } - public final [CONTRACTS] fun receive(value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } + public final [CONTRACTS] fun receive([STATUS] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } public final [CONTRACTS] fun functionWithLazyBody(): R|kotlin/String| { LAZY_BLOCK } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/delegates.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/delegates.txt index 54e11b255ca..579e34f42c2 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/delegates.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/delegates.txt @@ -5,41 +5,41 @@ FILE: delegates.kt R|/variableWithExplicitType| = Int(10) R|/variableWithImplicitType| = Int(10) } - public final [STATUS] fun receive(value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } + public final [STATUS] fun receive([STATUS] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } public final [IMPLICIT_TYPES_BODY_RESOLVE] val delegate: R|kotlin/properties/ReadWriteProperty| = object : R|kotlin/properties/ReadWriteProperty| { private [BODY_RESOLVE] constructor(): R|| { super() } - public final override operator [BODY_RESOLVE] fun getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|kotlin/Int| { + public final override operator [BODY_RESOLVE] fun getValue([BODY_RESOLVE] thisRef: R|kotlin/Any?|, [BODY_RESOLVE] property: R|kotlin/reflect/KProperty<*>|): R|kotlin/Int| { ^getValue Int(1) } - public final override operator [BODY_RESOLVE] fun setValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|, value: R|kotlin/Int|): R|kotlin/Unit| { + public final override operator [BODY_RESOLVE] fun setValue([BODY_RESOLVE] thisRef: R|kotlin/Any?|, [BODY_RESOLVE] property: R|kotlin/reflect/KProperty<*>|, [BODY_RESOLVE] value: R|kotlin/Int|): R|kotlin/Unit| { } } - public get(): R|kotlin/properties/ReadWriteProperty| + [IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/properties/ReadWriteProperty| public final [STATUS] val valueWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION - public get(): { + [STATUS] public get(): { ^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|) } public final [IMPLICIT_TYPES_BODY_RESOLVE] val valueWithImplicitType: R|kotlin/Int|by R|/delegate| - public get(): R|kotlin/Int| { + [IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| { ^ D|/valueWithImplicitType|.R|SubstitutionOverride|(Null(null), ::R|/valueWithImplicitType|) } public final [STATUS] var variableWithExplicitType: R|kotlin/Int|by LAZY_EXPRESSION - public get(): { + [STATUS] public get(): { ^ D|/variableWithExplicitType|.getValue#(Null(null), ::R|/variableWithExplicitType|) } - public set(: ): R|kotlin/Unit| { + [STATUS] public set([RAW_FIR] : ): R|kotlin/Unit| { D|/variableWithExplicitType|.setValue#(Null(null), ::R|/variableWithExplicitType|, R|/variableWithExplicitType|) } public final [IMPLICIT_TYPES_BODY_RESOLVE] var variableWithImplicitType: R|kotlin/Int|by R|/delegate| - public get(): R|kotlin/Int| { + [IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| { ^ D|/variableWithImplicitType|.R|SubstitutionOverride|(Null(null), ::R|/variableWithImplicitType|) } - public set(: R|kotlin/Int|): R|kotlin/Unit| { + [IMPLICIT_TYPES_BODY_RESOLVE] public set([IMPLICIT_TYPES_BODY_RESOLVE] : R|kotlin/Int|): R|kotlin/Unit| { D|/variableWithImplicitType|.R|SubstitutionOverride|(Null(null), ::R|/variableWithImplicitType|, R|/variableWithImplicitType|) } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetter.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetter.txt index 52e7c0988f3..4fa1ae8779d 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetter.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetter.txt @@ -2,6 +2,6 @@ FILE: propertyWithGetter.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { R|/receive|(R|/withGetter|) } - public final [STATUS] fun receive(value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } + public final [STATUS] fun receive([STATUS] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } public final [STATUS] val withGetter: R|kotlin/Int| - public get(): R|kotlin/Int| { LAZY_BLOCK } + [STATUS] public get(): R|kotlin/Int| { LAZY_BLOCK } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetterAndSetter.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetterAndSetter.txt index fab22f04a03..ee46ab0fb5d 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetterAndSetter.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetterAndSetter.txt @@ -3,7 +3,7 @@ FILE: propertyWithGetterAndSetter.kt R|/receive|(R|/withGetterAndSetter|) R|/withGetterAndSetter| = Int(123) } - public final [STATUS] fun receive(value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } + public final [STATUS] fun receive([STATUS] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } public final [STATUS] var withGetterAndSetter: R|kotlin/Int| = LAZY_EXPRESSION - public get(): R|kotlin/Int| { LAZY_BLOCK } - public set(value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } + [STATUS] public get(): R|kotlin/Int| { LAZY_BLOCK } + [STATUS] public set([RAW_FIR] value: R|kotlin/Int|): R|kotlin/Unit| { LAZY_BLOCK } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithInitializer.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithInitializer.txt index 247d1b02a92..80a8e1f5897 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithInitializer.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithInitializer.txt @@ -3,4 +3,4 @@ FILE: propertyWithInitializer.kt #(R|/property|) } public final [STATUS] val property: R|kotlin/Int| = LAZY_EXPRESSION - public get(): R|kotlin/Int| + [STATUS] public get(): R|kotlin/Int| diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/secondaryConstructor.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/secondaryConstructor.txt index 47e22d827ab..df0566fccfe 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/secondaryConstructor.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/secondaryConstructor.txt @@ -2,8 +2,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(value: R|A|): R|kotlin/Unit| { LAZY_BLOCK } + public final [STATUS] fun receive([STATUS] value: R|A|): R|kotlin/Unit| { LAZY_BLOCK } public final [STATUS] class A : R|kotlin/Any| { - public [STATUS] constructor(x: R|kotlin/Int|): R|A| { LAZY_BLOCK } + public [STATUS] constructor([STATUS] x: R|kotlin/Int|): R|A| { LAZY_BLOCK } } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctions.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctions.txt index 2d110225751..96d5ba8c505 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctions.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctions.txt @@ -2,5 +2,5 @@ FILE: topLevelFunctions.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { R|/receive|(R|/functionWithLazyBody|()) } - public final [STATUS] fun receive(value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } + public final [STATUS] fun receive([STATUS] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| { LAZY_BLOCK } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt index f5fd7355874..00089ca7966 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt @@ -2,5 +2,5 @@ FILE: topLevelFunctionsWithExpressionBodyAndExplicitType.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { R|/receive|(R|/functionWithLazyBody|()) } - public final [STATUS] fun receive(value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } + public final [STATUS] fun receive([STATUS] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| { LAZY_BLOCK } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt index fed74e1133d..389bdce4d79 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt @@ -2,7 +2,7 @@ FILE: topLevelFunctionsWithImplicitType.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { R|/receive|(R|/functionWithLazyBody|()) } - public final [STATUS] fun receive(value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } + public final [STATUS] fun receive([STATUS] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } public final [IMPLICIT_TYPES_BODY_RESOLVE] fun functionWithLazyBody(): R|kotlin/String| { ^functionWithLazyBody String(42) } diff --git a/idea/testData/fir/lazyResolve/elvis/main.txt b/idea/testData/fir/lazyResolve/elvis/main.txt index 27f53e95fde..9cb8d8909ca 100644 --- a/idea/testData/fir/lazyResolve/elvis/main.txt +++ b/idea/testData/fir/lazyResolve/elvis/main.txt @@ -1,11 +1,11 @@ FILE: main.kt public final [CONTRACTS] class WithElvis : R|kotlin/Any| { - public [CONTRACTS] constructor(value: R|kotlin/String?|): R|elvis/WithElvis| { + public [CONTRACTS] constructor([STATUS] value: R|kotlin/String?|): R|elvis/WithElvis| { super() } public final [CONTRACTS] val value: R|kotlin/String?| = R|/value| - public get(): R|kotlin/String?| + [STATUS] public get(): R|kotlin/String?| public final [BODY_RESOLVE] fun foo(): R|kotlin/String| { ^foo this@R|elvis/WithElvis|.R|elvis/WithElvis.value| ?: String() diff --git a/idea/testData/fir/lazyResolve/inInit/main.txt b/idea/testData/fir/lazyResolve/inInit/main.txt index 02321541b3e..3abe0866232 100644 --- a/idea/testData/fir/lazyResolve/inInit/main.txt +++ b/idea/testData/fir/lazyResolve/inInit/main.txt @@ -5,7 +5,7 @@ FILE: main.kt } public final [BODY_RESOLVE] val x: R|kotlin/Int| - public get(): R|kotlin/Int| + [BODY_RESOLVE] public get(): R|kotlin/Int| init { this@R|/Foo|.R|/Foo.x| = Int(42) diff --git a/idea/testData/fir/lazyResolve/inSecondary/main.txt b/idea/testData/fir/lazyResolve/inSecondary/main.txt index a7d90399fd8..573a5070e95 100644 --- a/idea/testData/fir/lazyResolve/inSecondary/main.txt +++ b/idea/testData/fir/lazyResolve/inSecondary/main.txt @@ -1,7 +1,7 @@ FILE: main.kt public final [CONTRACTS] class Foo : R|kotlin/Any| { public final [CONTRACTS] val x: R|kotlin/Int| - public get(): R|kotlin/Int| + [STATUS] public get(): R|kotlin/Int| public [BODY_RESOLVE] constructor(): R|Foo| { super() diff --git a/idea/testData/fir/lazyResolve/simple/main.txt b/idea/testData/fir/lazyResolve/simple/main.txt index 14a8ed78cd3..f68a9fa1b1d 100644 --- a/idea/testData/fir/lazyResolve/simple/main.txt +++ b/idea/testData/fir/lazyResolve/simple/main.txt @@ -7,6 +7,6 @@ FILE: main.kt public final [STATUS] fun foo(): R|kotlin/Unit| { [RAW_FIR] lval y: = Double(2.0) } - public final [IMPLICIT_TYPES_BODY_RESOLVE] fun bar(x: R|kotlin/Int|, y: R|kotlin/Int|): R|kotlin/Int| { + public final [IMPLICIT_TYPES_BODY_RESOLVE] fun bar([IMPLICIT_TYPES_BODY_RESOLVE] x: R|kotlin/Int|, [IMPLICIT_TYPES_BODY_RESOLVE] y: R|kotlin/Int|): R|kotlin/Int| { ^bar R|/x|.R|kotlin/Int.plus|(R|/y|) } diff --git a/idea/testData/fir/lazyResolve/simpleProperty/myProperty.txt b/idea/testData/fir/lazyResolve/simpleProperty/myProperty.txt index 93d6a9ae7a4..db3f86429d4 100644 --- a/idea/testData/fir/lazyResolve/simpleProperty/myProperty.txt +++ b/idea/testData/fir/lazyResolve/simpleProperty/myProperty.txt @@ -1,5 +1,5 @@ FILE: myProperty.kt public final [IMPLICIT_TYPES_BODY_RESOLVE] val myProperty: R|kotlin/Int| - public get(): R|kotlin/Int| { + [IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| { ^ Int(42) }