[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
+2
-2
@@ -77,7 +77,7 @@ internal object FirReferenceResolveHelper {
|
||||
val callee = calleeReference.resolvedSymbol.fir as? FirCallableDeclaration
|
||||
// TODO: check callee owner directly?
|
||||
if (callee !is FirConstructor && callee?.isStatic != true) {
|
||||
classLikeDeclaration.companionObject?.let { return it.buildSymbol(symbolBuilder) }
|
||||
classLikeDeclaration.companionObjectSymbol?.let { return it.fir.buildSymbol(symbolBuilder) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -398,7 +398,7 @@ internal object FirReferenceResolveHelper {
|
||||
symbolBuilder: KtSymbolByFirBuilder
|
||||
): Collection<KtSymbol> {
|
||||
val referencedSymbol = if (fir.resolvedToCompanionObject) {
|
||||
(fir.symbol?.fir as? FirRegularClass)?.companionObject?.symbol
|
||||
(fir.symbol?.fir as? FirRegularClass)?.companionObjectSymbol
|
||||
} else {
|
||||
fir.symbol
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ internal class KtFirNamedClassOrObjectSymbol(
|
||||
override val isExternal: Boolean get() = firRef.withFir { it.isExternal }
|
||||
|
||||
override val companionObject: KtFirNamedClassOrObjectSymbol? by firRef.withFirAndCache { fir ->
|
||||
fir.companionObject?.let { builder.classifierBuilder.buildNamedClassOrObjectSymbol(it) }
|
||||
fir.companionObjectSymbol?.let { builder.classifierBuilder.buildNamedClassOrObjectSymbol(it.fir) }
|
||||
}
|
||||
|
||||
override val superTypes: List<KtType> by cached {
|
||||
|
||||
Reference in New Issue
Block a user