[FIR] Synthetic property symbol is now a property symbol, not a function

This commit is contained in:
Mikhail Glukhikh
2020-02-05 12:44:53 +03:00
parent 17e1f081c7
commit 69809fef94
6 changed files with 277 additions and 17 deletions
@@ -0,0 +1,139 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.declarations.synthetic
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference
import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.FirTransformer
import org.jetbrains.kotlin.fir.visitors.FirVisitor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
class FirSyntheticProperty(
override val session: FirSession,
override val returnTypeRef: FirTypeRef,
override val name: Name,
override val isVar: Boolean,
override val symbol: FirPropertySymbol,
override val status: FirDeclarationStatus,
override val resolvePhase: FirResolvePhase,
override val getter: FirSyntheticPropertyAccessor,
override val setter: FirSyntheticPropertyAccessor? = null
) : FirProperty() {
init {
symbol.bind(this)
}
constructor(
session: FirSession,
name: Name,
symbol: FirPropertySymbol,
delegateGetter: FirSimpleFunction
) : this(
session, delegateGetter.returnTypeRef, name, false, symbol,
FirDeclarationStatusImpl(delegateGetter.visibility, delegateGetter.modality),
delegateGetter.resolvePhase,
FirSyntheticPropertyAccessor(delegateGetter, isGetter = true)
)
override val source: FirSourceElement?
get() = null
override val initializer: FirExpression?
get() = null
override val delegate: FirExpression?
get() = null
override val delegateFieldSymbol: FirDelegateFieldSymbol<FirProperty>?
get() = null
override val isLocal: Boolean
get() = false
override val receiverTypeRef: FirTypeRef?
get() = null
override val isVal: Boolean
get() = !isVar
override val annotations: List<FirAnnotationCall>
get() = emptyList()
override val typeParameters: List<FirTypeParameter>
get() = emptyList()
override val containerSource: DeserializedContainerSource?
get() = null
override val controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference
// ???
override val backingFieldSymbol: FirBackingFieldSymbol = FirBackingFieldSymbol(symbol.callableId)
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
returnTypeRef.accept(visitor, data)
status.accept(visitor, data)
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformControlFlowGraphReference(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformStatus(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformOtherChildren(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformGetter(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun <D> transformSetter(transformer: FirTransformer<D>, data: D): FirSyntheticProperty {
throw AssertionError("Transformation of synthetic property isn't supported")
}
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) {
throw AssertionError("Mutation of synthetic property isn't supported")
}
override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) {
throw AssertionError("Mutation of synthetic property isn't supported")
}
override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {
throw AssertionError("Mutation of synthetic property isn't supported")
}
}
@@ -0,0 +1,121 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.declarations.synthetic
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.contracts.FirContractDescription
import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyAccessorImpl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirBlock
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.FirTransformer
import org.jetbrains.kotlin.fir.visitors.FirVisitor
class FirSyntheticPropertyAccessor(
private val delegate: FirSimpleFunction,
override val isGetter: Boolean
) : FirPropertyAccessor() {
override val source: FirSourceElement?
get() = delegate.source
override val session: FirSession
get() = delegate.session
override val returnTypeRef: FirTypeRef
get() = delegate.returnTypeRef
override val resolvePhase: FirResolvePhase
get() = delegate.resolvePhase
override val status: FirDeclarationStatus
get() = delegate.status
override val receiverTypeRef: FirTypeRef?
get() = null
override val valueParameters: List<FirValueParameter>
get() = delegate.valueParameters
override val annotations: List<FirAnnotationCall>
get() = delegate.annotations
override val typeParameters: List<FirTypeParameter>
get() = emptyList()
override val isSetter: Boolean
get() = !isGetter
override val body: FirBlock?
get() = delegate.body
override val symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol().apply {
bind(this@FirSyntheticPropertyAccessor)
}
override val controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference
override val contractDescription: FirContractDescription = FirEmptyContractDescription
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
delegate.accept(visitor, data)
controlFlowGraphReference.accept(visitor, data)
contractDescription.accept(visitor, data)
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirPropertyAccessorImpl {
throw AssertionError("Transformation of synthetic property accessor isn't supported")
}
override fun <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirPropertyAccessorImpl {
throw AssertionError("Transformation of synthetic property accessor isn't supported")
}
override fun <D> transformReceiverTypeRef(transformer: FirTransformer<D>, data: D): FirPropertyAccessorImpl {
throw AssertionError("Transformation of synthetic property accessor isn't supported")
}
override fun <D> transformControlFlowGraphReference(transformer: FirTransformer<D>, data: D): FirPropertyAccessorImpl {
throw AssertionError("Transformation of synthetic property accessor isn't supported")
}
override fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirPropertyAccessorImpl {
throw AssertionError("Transformation of synthetic property accessor isn't supported")
}
override fun <D> transformContractDescription(transformer: FirTransformer<D>, data: D): FirPropertyAccessorImpl {
throw AssertionError("Transformation of synthetic property accessor isn't supported")
}
override fun <D> transformStatus(transformer: FirTransformer<D>, data: D): FirPropertyAccessorImpl {
throw AssertionError("Transformation of synthetic property accessor isn't supported")
}
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) {
throw AssertionError("Mutation of synthetic property accessor isn't supported")
}
override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) {
throw AssertionError("Mutation of synthetic property accessor isn't supported")
}
override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {
throw AssertionError("Mutation of synthetic property accessor isn't supported")
}
override fun replaceValueParameters(newValueParameters: List<FirValueParameter>) {
throw AssertionError("Mutation of synthetic property accessor isn't supported")
}
override fun replaceContractDescription(newContractDescription: FirContractDescription) {
throw AssertionError("Mutation of synthetic property accessor isn't supported")
}
}