[FIR] Make FirRegularClass.companionObject companionObjectSymbol field
This is needed for two reasons: 1. Before this change companion object appeared in FirRegularClass twice: in declarations list and in companionObject field. This may trigger twice transform of it 2. It's very hard to implement generation of companion object by plugins because if it is part of the tree then generated declaration must be registered in FirProvider, which is inconsistent with other generated declarations. Replacing FIR with symbol and removing custom logic of visiting/transforming companion FIR allows us to just replace companionSymbol in FirClass if plugin wants to generate it without any additional work
This commit is contained in:
committed by
teamcityserver
parent
01deac5e5c
commit
75b6f7ca00
+3
-3
@@ -54,7 +54,7 @@ data class ImplicitReceivers(
|
||||
fun SessionHolder.collectTowerDataElementsForClass(owner: FirClass, defaultType: ConeKotlinType): TowerElementsForClass {
|
||||
val allImplicitCompanionValues = mutableListOf<ImplicitReceiverValue<*>>()
|
||||
|
||||
val companionObject = (owner as? FirRegularClass)?.companionObject
|
||||
val companionObject = (owner as? FirRegularClass)?.companionObjectSymbol?.fir
|
||||
val companionReceiver = companionObject?.let { companion ->
|
||||
ImplicitDispatchReceiverValue(
|
||||
companion.symbol, session, scopeSession
|
||||
@@ -72,9 +72,9 @@ fun SessionHolder.collectTowerDataElementsForClass(owner: FirClass, defaultType:
|
||||
?.asTowerDataElement(isLocal = false)
|
||||
?.let(superClassesStaticsAndCompanionReceivers::add)
|
||||
|
||||
(superClass as? FirRegularClass)?.companionObject?.let { companion ->
|
||||
(superClass as? FirRegularClass)?.companionObjectSymbol?.let {
|
||||
val superCompanionReceiver = ImplicitDispatchReceiverValue(
|
||||
companion.symbol, session, scopeSession
|
||||
it, session, scopeSession
|
||||
)
|
||||
|
||||
superClassesStaticsAndCompanionReceivers += superCompanionReceiver.asTowerDataElement()
|
||||
|
||||
Reference in New Issue
Block a user