From 63f38bb28ab79d9bccb3cffd881c37af30d47647 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 14 Nov 2019 15:34:59 +0300 Subject: [PATCH] FIR [rendering only]: render fake overrides for properties --- .../resolve/expresssions/extensionPropertyInLambda.txt | 4 ++-- .../resolve/expresssions/genericPropertyAccess.txt | 2 +- .../testData/resolve/stdlib/j+k/StaticGenericMethod.txt | 2 +- .../fir/resolve/testData/resolve/stdlib/problems.txt | 2 +- .../fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt | 9 ++++++--- .../ir/irText/types/genericPropertyReferenceType.fir.txt | 2 +- .../types/smartCastOnReceiverOfGenericType.fir.txt | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt b/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt index ed9fc5719bd..6785bfc9bca 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt @@ -11,10 +11,10 @@ FILE: extensionPropertyInLambda.kt } public final var R|C|.y: R|T| public get(): R|T| { - ^ this@R|/C|.R|/C.x| + ^ this@R|/C|.R|FakeOverride| } public set(v: R|T|): R|kotlin/Unit| { - this@R|/C|.R|/C.x| = R|/v| + this@R|/C|.R|FakeOverride| = R|/v| } public final fun use(f: R|() -> kotlin/String|): R|kotlin/Unit| { } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/genericPropertyAccess.txt b/compiler/fir/resolve/testData/resolve/expresssions/genericPropertyAccess.txt index f10c4bd12aa..0a569532908 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/genericPropertyAccess.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/genericPropertyAccess.txt @@ -16,7 +16,7 @@ FILE: genericPropertyAccess.kt } public final override fun foo(): R|T| { - ^foo this@R|/Base|.R|/Base.x| + ^foo this@R|/Base|.R|FakeOverride| } } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/StaticGenericMethod.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/StaticGenericMethod.txt index 381889a0be2..d2614e93033 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/StaticGenericMethod.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/StaticGenericMethod.txt @@ -13,7 +13,7 @@ FILE: User.kt protected abstract fun createSettings(): R|T| public final fun foo(): R|kotlin/Unit| { - this@R|/User|.R|/User.settings| = Q|StaticOwner|.R|/StaticOwner.newInstance|(this@R|/User|.R|/User.settings|.R|kotlin/jvm/javaClass|) + this@R|/User|.R|FakeOverride| = Q|StaticOwner|.R|/StaticOwner.newInstance|(this@R|/User|.R|FakeOverride|.R|kotlin/jvm/javaClass|) } } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems.txt b/compiler/fir/resolve/testData/resolve/stdlib/problems.txt index 0500b8a8f5d..bef1f816905 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/problems.txt @@ -53,7 +53,7 @@ FILE: problems.kt } } - public final val xx: R|kotlin/Int| = R|/Derived.Derived|().R|/Base.x|.R|kotlin/Int.plus|(Int(1)) + public final val xx: R|kotlin/Int| = R|/Derived.Derived|().R|FakeOverride|.R|kotlin/Int.plus|(Int(1)) public get(): R|kotlin/Int| public final val t: R|kotlin/Nothing| = throw R|java/lang/AssertionError.AssertionError|(String()) public get(): R|kotlin/Nothing| 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 e7b21c896d6..b35ed8685be 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -25,7 +25,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.types.Variance @@ -821,12 +820,16 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) { print("R|") - val isFakeOverride = (resolvedNamedReference.resolvedSymbol as? FirNamedFunctionSymbol)?.isFakeOverride == true + val symbol = resolvedNamedReference.resolvedSymbol + val isFakeOverride = when (symbol) { + is FirNamedFunctionSymbol -> symbol.isFakeOverride + is FirPropertySymbol -> symbol.isFakeOverride + else -> false + } if (isFakeOverride) { print("FakeOverride<") } - val symbol = resolvedNamedReference.resolvedSymbol print(symbol.render()) diff --git a/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt b/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt index ea7cc7cbe1e..3a44245c4fd 100644 --- a/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt +++ b/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt @@ -50,7 +50,7 @@ FILE fqName: fileName:/genericPropertyReferenceType.kt correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var] VALUE_PARAMETER name:v index:0 type:T of BLOCK_BODY - ERROR_CALL 'Unresolved reference: R|/C.x|' type=IrErrorType + ERROR_CALL 'Unresolved reference: R|FakeOverride|' type=IrErrorType FUN name:use visibility:public modality:FINAL <> (p:kotlin.reflect.KMutableProperty) returnType:kotlin.Unit VALUE_PARAMETER name:p index:0 type:kotlin.reflect.KMutableProperty BLOCK_BODY diff --git a/compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.fir.txt b/compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.fir.txt index a8ca63afc1e..3389055e929 100644 --- a/compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.fir.txt +++ b/compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.fir.txt @@ -18,7 +18,7 @@ FILE fqName: fileName:/smartCastOnReceiverOfGenericType.kt GET_VAR 'a: kotlin.Any declared in .testProperty' type=kotlin.Any origin=null TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String GET_VAR 'b: kotlin.Any declared in .testProperty' type=kotlin.Any origin=null - ERROR_CALL 'Unresolved reference: R|/Cell.value|' type=IrErrorType + ERROR_CALL 'Unresolved reference: R|FakeOverride|' type=IrErrorType FUN name:testInnerClass visibility:public modality:FINAL <> (a:kotlin.Any, b:kotlin.Any, c:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any VALUE_PARAMETER name:b index:1 type:kotlin.Any