[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:
Dmitriy Novozhilov
2021-10-18 18:37:14 +03:00
committed by teamcityserver
parent 01deac5e5c
commit 75b6f7ca00
29 changed files with 50 additions and 67 deletions
@@ -780,7 +780,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: StringBuilder) {
val fir = resolvedQualifier.symbol?.fir
when {
fir is FirRegularClass && fir.classKind != ClassKind.ENUM_CLASS && fir.companionObject?.defaultType() == resolvedQualifier.typeRef.coneTypeSafe() -> {
fir is FirRegularClass && fir.classKind != ClassKind.ENUM_CLASS && fir.companionObjectSymbol?.defaultType() == resolvedQualifier.typeRef.coneTypeSafe() -> {
data.append("companion object ")
data.append(resolvedQualifier.typeRef.render()).append(": ")
data.append(fir.symbol.classId.asString().removeCurrentFilePackage())