[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
@@ -61,9 +61,6 @@ class FirJavaClass @FirImplementationDetail internal constructor(
|
||||
|
||||
override val attributes: FirDeclarationAttributes = FirDeclarationAttributes()
|
||||
|
||||
override val companionObject: FirRegularClass?
|
||||
get() = null
|
||||
|
||||
override fun replaceSuperTypeRefs(newSuperTypeRefs: List<FirTypeRef>) {
|
||||
superTypeRefs.clear()
|
||||
superTypeRefs.addAll(newSuperTypeRefs)
|
||||
@@ -79,6 +76,11 @@ class FirJavaClass @FirImplementationDetail internal constructor(
|
||||
|
||||
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {}
|
||||
|
||||
override val companionObjectSymbol: FirRegularClassSymbol?
|
||||
get() = null
|
||||
|
||||
override fun replaceCompanionObjectSymbol(newCompanionObjectSymbol: FirRegularClassSymbol?) {}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
declarations.forEach { it.accept(visitor, data) }
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
@@ -116,10 +118,6 @@ class FirJavaClass @FirImplementationDetail internal constructor(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformCompanionObject(transformer: FirTransformer<D>, data: D): FirJavaClass {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirRegularClass {
|
||||
typeParameters.transformInplace(transformer, data)
|
||||
return this
|
||||
@@ -166,13 +164,6 @@ internal class FirJavaClassBuilder : FirRegularClassBuilder(), FirAnnotationCont
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'hasLazyNestedClassifiers' has no impact for FirRegularClassImplBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var companionObject: FirRegularClass?
|
||||
get() = throw IllegalStateException()
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'origin' has no impact for FirJavaClassBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var origin: FirDeclarationOrigin
|
||||
get() = throw IllegalStateException()
|
||||
|
||||
Reference in New Issue
Block a user