[FIR] Add some safe API to synthetic property symbols
Previously there were no way to get delegated function symbol of accessor symbol of synthetic property
This commit is contained in:
committed by
Space Team
parent
be6694f049
commit
d5b0a5b220
+2
-2
@@ -15,8 +15,8 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyAccessorImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirSyntheticPropertyAccessorSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeSimpleKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
@@ -70,7 +70,7 @@ class FirSyntheticPropertyAccessor @FirImplementationDetail internal constructor
|
||||
override val attributes: FirDeclarationAttributes
|
||||
get() = delegate.attributes
|
||||
|
||||
override val symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol().apply {
|
||||
override val symbol: FirSyntheticPropertyAccessorSymbol = FirSyntheticPropertyAccessorSymbol().apply {
|
||||
bind(this@FirSyntheticPropertyAccessor)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,11 @@ import org.jetbrains.kotlin.fir.FirLabel
|
||||
import org.jetbrains.kotlin.fir.contracts.FirResolvedContractDescription
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.toResolvedConstructorSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.mpp.ConstructorSymbolMarker
|
||||
import org.jetbrains.kotlin.mpp.FunctionSymbolMarker
|
||||
@@ -83,8 +85,15 @@ class FirConstructorSymbol(callableId: CallableId) : FirFunctionSymbol<FirConstr
|
||||
abstract class FirSyntheticPropertySymbol(propertyId: CallableId, val getterId: CallableId) : FirPropertySymbol(propertyId) {
|
||||
abstract fun copy(): FirSyntheticPropertySymbol
|
||||
|
||||
@SymbolInternals
|
||||
val syntheticProperty: FirSyntheticProperty
|
||||
get() = fir as FirSyntheticProperty
|
||||
|
||||
override val getterSymbol: FirSyntheticPropertyAccessorSymbol?
|
||||
get() = super.getterSymbol as FirSyntheticPropertyAccessorSymbol?
|
||||
|
||||
override val setterSymbol: FirSyntheticPropertyAccessorSymbol?
|
||||
get() = super.setterSymbol as FirSyntheticPropertyAccessorSymbol?
|
||||
}
|
||||
|
||||
// ------------------------ unnamed ------------------------
|
||||
@@ -95,10 +104,18 @@ class FirAnonymousFunctionSymbol : FirFunctionWithoutNameSymbol<FirAnonymousFunc
|
||||
val label: FirLabel? get() = fir.label
|
||||
}
|
||||
|
||||
class FirPropertyAccessorSymbol : FirFunctionWithoutNameSymbol<FirPropertyAccessor>(Name.identifier("accessor")) {
|
||||
open class FirPropertyAccessorSymbol : FirFunctionWithoutNameSymbol<FirPropertyAccessor>(Name.identifier("accessor")) {
|
||||
val isGetter: Boolean get() = fir.isGetter
|
||||
val isSetter: Boolean get() = fir.isSetter
|
||||
val propertySymbol get() = fir.propertySymbol
|
||||
open val propertySymbol: FirPropertySymbol get() = fir.propertySymbol
|
||||
}
|
||||
|
||||
class FirSyntheticPropertyAccessorSymbol : FirPropertyAccessorSymbol() {
|
||||
override val propertySymbol: FirSyntheticPropertySymbol
|
||||
get() = super.propertySymbol as FirSyntheticPropertySymbol
|
||||
|
||||
val delegateFunctionSymbol: FirNamedFunctionSymbol
|
||||
get() = (fir as FirSyntheticPropertyAccessor).delegate.symbol
|
||||
}
|
||||
|
||||
class FirErrorFunctionSymbol : FirFunctionWithoutNameSymbol<FirErrorFunction>(Name.identifier("error"))
|
||||
|
||||
@@ -26,10 +26,10 @@ open class FirPropertySymbol(callableId: CallableId, ) : FirVariableSymbol<FirPr
|
||||
val isLocal: Boolean
|
||||
get() = fir.isLocal
|
||||
|
||||
val getterSymbol: FirPropertyAccessorSymbol?
|
||||
open val getterSymbol: FirPropertyAccessorSymbol?
|
||||
get() = fir.getter?.symbol
|
||||
|
||||
val setterSymbol: FirPropertyAccessorSymbol?
|
||||
open val setterSymbol: FirPropertyAccessorSymbol?
|
||||
get() = fir.setter?.symbol
|
||||
|
||||
val backingFieldSymbol: FirBackingFieldSymbol?
|
||||
|
||||
Reference in New Issue
Block a user