From 9107944b053b7b4bcd2c8a6eb29ebc078ef5c572 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 14 Jul 2020 18:20:37 +0300 Subject: [PATCH] FirSyntheticProperty: take returnTypeRef directly from delegate --- .../body/resolve/FirDeclarationsResolveTransformer.kt | 1 - .../fir/declarations/synthetic/FirSyntheticProperty.kt | 6 ++++-- .../declarations/synthetic/FirSyntheticPropertyBuilder.kt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index d5d7e07a2c8..2a5894ff967 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -98,7 +98,6 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor override fun transformProperty(property: FirProperty, data: ResolutionMode): CompositeTransformResult { if (property is FirSyntheticProperty) { transformSimpleFunction(property.getter.delegate, data) - property.replaceReturnTypeRef(property.getter.delegate.returnTypeRef) return property.compose() } return withTypeParametersOf(property) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt index 4e5d3759549..325a77f7d68 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ class FirSyntheticProperty( override val session: FirSession, - override var returnTypeRef: FirTypeRef, override val name: Name, override val isVar: Boolean, override val symbol: FirAccessorSymbol, @@ -36,6 +35,9 @@ class FirSyntheticProperty( symbol.bind(this) } + override val returnTypeRef: FirTypeRef + get() = getter.returnTypeRef + override val source: FirSourceElement? get() = null @@ -130,7 +132,7 @@ class FirSyntheticProperty( } override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) { - returnTypeRef = newReturnTypeRef + throw AssertionError("Mutation of synthetic property isn't supported") } override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyBuilder.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyBuilder.kt index b9a965ac31a..d675d2c9ceb 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyBuilder.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyBuilder.kt @@ -21,7 +21,7 @@ class FirSyntheticPropertyBuilder { var delegateSetter: FirSimpleFunction? = null fun build(): FirSyntheticProperty = FirSyntheticProperty( - session, delegateGetter.returnTypeRef, name, isVar = delegateSetter != null, symbol = symbol, + session, name, isVar = delegateSetter != null, symbol = symbol, status = FirDeclarationStatusImpl(delegateGetter.visibility, delegateGetter.modality), resolvePhase = delegateGetter.resolvePhase, getter = FirSyntheticPropertyAccessor(delegateGetter, isGetter = true),