diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractElementDeclarationImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractElementDeclarationImpl.kt index 6b413ae2789..26c1a81ec16 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractElementDeclarationImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirContractElementDeclarationImpl.kt @@ -20,6 +20,7 @@ internal class FirContractElementDeclarationImpl( override val source: KtSourceElement?, override val effect: ConeContractDescriptionElement, ) : FirContractElementDeclaration() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirContractElementDeclarationImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt index 47b0d85566d..af17ae479e8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt @@ -20,6 +20,7 @@ internal class FirEffectDeclarationImpl( override val source: KtSourceElement?, override val effect: ConeEffectDeclaration, ) : FirEffectDeclaration() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirEffectDeclarationImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt index 34638e5af56..20e4381349e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt @@ -22,6 +22,7 @@ internal class FirLegacyRawContractDescriptionImpl( override var contractCall: FirFunctionCall, override val diagnostic: ConeDiagnostic?, ) : FirLegacyRawContractDescription() { + override fun acceptChildren(visitor: FirVisitor, data: D) { contractCall.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt index 6a3849907be..6e7876c8399 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt @@ -21,6 +21,7 @@ internal class FirRawContractDescriptionImpl( override val source: KtSourceElement?, override val rawEffects: MutableList, ) : FirRawContractDescription() { + override fun acceptChildren(visitor: FirVisitor, data: D) { rawEffects.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt index 5dfd1d83d36..0beb44fdb79 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt @@ -25,6 +25,7 @@ internal class FirResolvedContractDescriptionImpl( override val unresolvedEffects: MutableList, override val diagnostic: ConeDiagnostic?, ) : FirResolvedContractDescription() { + override fun acceptChildren(visitor: FirVisitor, data: D) { effects.forEach { it.accept(visitor, data) } unresolvedEffects.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt index 9cadbe006c7..0cce0f64e01 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt @@ -57,6 +57,7 @@ internal class FirAnonymousFunctionImpl( override val typeParameters: MutableList, override var typeRef: FirTypeRef, ) : FirAnonymousFunction() { + init { symbol.bind(this) resolveState = resolvePhase.asResolveState() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt index 2e302d070be..acf7c81615e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirBackingFieldImpl.kt @@ -55,6 +55,7 @@ open class FirBackingFieldImpl @FirImplementationDetail constructor( override val typeParameters: MutableList, override var status: FirDeclarationStatus, ) : FirBackingField() { + init { symbol.bind(this) resolveState = resolvePhase.asResolveState() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirCodeFragmentImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirCodeFragmentImpl.kt index 2e0d5521dce..5d1897ede0f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirCodeFragmentImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirCodeFragmentImpl.kt @@ -33,6 +33,7 @@ internal class FirCodeFragmentImpl( override val symbol: FirCodeFragmentSymbol, override var block: FirBlock, ) : FirCodeFragment() { + init { symbol.bind(this) resolveState = resolvePhase.asResolveState() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRefImpl.kt index f425a458c27..b0d7d8877fb 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRefImpl.kt @@ -20,6 +20,7 @@ internal class FirConstructedClassTypeParameterRefImpl( override val source: KtSourceElement?, override val symbol: FirTypeParameterSymbol, ) : FirConstructedClassTypeParameterRef() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirConstructedClassTypeParameterRefImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirContextReceiverImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirContextReceiverImpl.kt index 44b68ff7f6e..e1255f5983b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirContextReceiverImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirContextReceiverImpl.kt @@ -23,6 +23,7 @@ internal class FirContextReceiverImpl( override val customLabelName: Name?, override val labelNameFromTypeRef: Name?, ) : FirContextReceiver() { + override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDanglingModifierListImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDanglingModifierListImpl.kt index 0c8a08d0c08..314576d8b58 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDanglingModifierListImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDanglingModifierListImpl.kt @@ -33,6 +33,7 @@ internal class FirDanglingModifierListImpl( override val diagnostic: ConeDiagnostic, override val symbol: FirDanglingModifierSymbol, ) : FirDanglingModifierList() { + init { symbol.bind(this) resolveState = resolvePhase.asResolveState() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt index 54939282278..b2d7049ca44 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt @@ -24,6 +24,7 @@ internal class FirImportImpl( override val aliasName: Name?, override val aliasSource: KtSourceElement?, ) : FirImport() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirImportImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRefImpl.kt index f0e020924e1..9638a8aaf59 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRefImpl.kt @@ -21,6 +21,7 @@ class FirOuterClassTypeParameterRefImpl @FirImplementationDetail constructor( override val source: KtSourceElement?, override val symbol: FirTypeParameterSymbol, ) : FirOuterClassTypeParameterRef() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirOuterClassTypeParameterRefImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirReceiverParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirReceiverParameterImpl.kt index 11ef71698cf..1639101b296 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirReceiverParameterImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirReceiverParameterImpl.kt @@ -25,6 +25,7 @@ internal class FirReceiverParameterImpl( override var typeRef: FirTypeRef, override var annotations: MutableOrEmptyList, ) : FirReceiverParameter() { + override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirScriptImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirScriptImpl.kt index 03b1ddb1f41..7c5079df8b0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirScriptImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirScriptImpl.kt @@ -38,6 +38,7 @@ internal class FirScriptImpl( override var contextReceivers: MutableOrEmptyList, override val resultPropertyName: Name?, ) : FirScript() { + init { symbol.bind(this) resolveState = resolvePhase.asResolveState() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt index a15cf0808d3..900bc489c0d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt @@ -38,6 +38,7 @@ internal class FirTypeAliasImpl( override var expandedTypeRef: FirTypeRef, override var annotations: MutableOrEmptyList, ) : FirTypeAlias() { + init { symbol.bind(this) resolveState = resolvePhase.asResolveState() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt index 1c8d9a9096d..d93c3645a53 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt @@ -40,6 +40,7 @@ internal class FirTypeParameterImpl( override val bounds: MutableList, override var annotations: MutableOrEmptyList, ) : FirTypeParameter() { + init { symbol.bind(this) resolveState = resolvePhase.asResolveState() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayLiteralImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayLiteralImpl.kt index 0166e0d8186..c9651f27378 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayLiteralImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayLiteralImpl.kt @@ -30,6 +30,7 @@ internal class FirArrayLiteralImpl( override var annotations: MutableOrEmptyList, override var argumentList: FirArgumentList, ) : FirArrayLiteral() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt index d9ff4e12349..a1d30be6733 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt @@ -28,6 +28,7 @@ internal class FirAssignmentOperatorStatementImpl( override var leftArgument: FirExpression, override var rightArgument: FirExpression, ) : FirAssignmentOperatorStatement() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } leftArgument.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt index 0b02cbacf9e..1d31b98b5ee 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt @@ -28,6 +28,7 @@ internal class FirAugmentedArraySetCallImpl( override var calleeReference: FirReference, override val arrayAccessSource: KtSourceElement?, ) : FirAugmentedArraySetCall() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } lhsGetCall.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt index 7759e98d285..2ea9b3640ab 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt @@ -33,6 +33,7 @@ internal class FirBinaryLogicExpressionImpl( override var rightOperand: FirExpression, override val kind: LogicOperationKind, ) : FirBinaryLogicExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } leftOperand.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt index f248e7f0e29..2c1e19ceb6c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt @@ -30,6 +30,7 @@ internal class FirBlockImpl( override var annotations: MutableOrEmptyList, override val statements: MutableList, ) : FirBlock() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } statements.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt index 79863fa4756..85ecf80d8e4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt @@ -42,6 +42,7 @@ internal class FirCallableReferenceAccessImpl( override var calleeReference: FirNamedReference, override var hasQuestionMarkAtLHS: Boolean, ) : FirCallableReferenceAccess() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } contextReceiverArguments.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt index cde48a5b05f..2de735aa5f4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt @@ -22,6 +22,7 @@ internal class FirCatchImpl( override var parameter: FirProperty, override var block: FirBlock, ) : FirCatch() { + override fun acceptChildren(visitor: FirVisitor, data: D) { parameter.accept(visitor, data) block.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt index cfbc7bad8e5..a0d9f5191f9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt @@ -32,6 +32,7 @@ internal class FirCheckNotNullCallImpl( override var argumentList: FirArgumentList, override var calleeReference: FirReference, ) : FirCheckNotNullCall() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt index c7dc6851983..13ec86ec1e1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt @@ -31,6 +31,7 @@ internal class FirCheckedSafeCallSubjectImpl( override var annotations: MutableOrEmptyList, override val originalReceiverRef: FirExpressionRef, ) : FirCheckedSafeCallSubject() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt index 890bb047d11..118232fa78a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt @@ -30,6 +30,7 @@ internal class FirClassReferenceExpressionImpl( override var annotations: MutableOrEmptyList, override var classTypeRef: FirTypeRef, ) : FirClassReferenceExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } classTypeRef.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt index a0973c6cb97..1f2d56e9a7b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt @@ -31,6 +31,7 @@ internal class FirConstExpressionImpl ( override var kind: ConstantValueKind, override val value: T, ) : FirConstExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDesugaredAssignmentValueReferenceExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDesugaredAssignmentValueReferenceExpressionImpl.kt index 51a9b11a5dd..86db37bea27 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDesugaredAssignmentValueReferenceExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDesugaredAssignmentValueReferenceExpressionImpl.kt @@ -31,6 +31,7 @@ internal class FirDesugaredAssignmentValueReferenceExpressionImpl( override var annotations: MutableOrEmptyList, override val expressionRef: FirExpressionRef, ) : FirDesugaredAssignmentValueReferenceExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt index 942bb989f41..d3e40137cb2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt @@ -29,6 +29,7 @@ internal class FirDoWhileLoopImpl( override var condition: FirExpression, override var label: FirLabel?, ) : FirDoWhileLoop() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } block.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt index 4f73c9f014e..5d3c52d90a6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt @@ -33,6 +33,7 @@ internal class FirElvisExpressionImpl( override var lhs: FirExpression, override var rhs: FirExpression, ) : FirElvisExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } calleeReference.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt index a1c4837a287..75bc9067e98 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt @@ -29,6 +29,7 @@ class FirExpressionStub @FirImplementationDetail constructor( override var coneTypeOrNull: ConeKotlinType?, override var annotations: MutableOrEmptyList, ) : FirExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt index fd86ccb8124..466eb2f2b11 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt @@ -40,6 +40,7 @@ open class FirFunctionCallImpl @FirImplementationDetail constructor( override var calleeReference: FirNamedReference, override val origin: FirFunctionCallOrigin, ) : FirFunctionCall() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } contextReceiverArguments.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirInaccessibleReceiverExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirInaccessibleReceiverExpressionImpl.kt index ae6f44e13b4..91e980704c9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirInaccessibleReceiverExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirInaccessibleReceiverExpressionImpl.kt @@ -31,6 +31,7 @@ internal class FirInaccessibleReceiverExpressionImpl( override var annotations: MutableOrEmptyList, override var calleeReference: FirThisReference, ) : FirInaccessibleReceiverExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } calleeReference.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIncrementDecrementExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIncrementDecrementExpressionImpl.kt index 4f5a7523edf..6e25a3561e4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIncrementDecrementExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIncrementDecrementExpressionImpl.kt @@ -34,6 +34,7 @@ internal class FirIncrementDecrementExpressionImpl( override var expression: FirExpression, override val operationSource: KtSourceElement?, ) : FirIncrementDecrementExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } expression.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIntegerLiteralOperatorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIntegerLiteralOperatorCallImpl.kt index bbb228c3f22..8a95f9bf177 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIntegerLiteralOperatorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIntegerLiteralOperatorCallImpl.kt @@ -40,6 +40,7 @@ internal class FirIntegerLiteralOperatorCallImpl( override var dispatchReceiver: FirExpression?, override var extensionReceiver: FirExpression?, ) : FirIntegerLiteralOperatorCall() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } contextReceiverArguments.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirPropertyAccessExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirPropertyAccessExpressionImpl.kt index 84bb963b750..652d51d6173 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirPropertyAccessExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirPropertyAccessExpressionImpl.kt @@ -40,6 +40,7 @@ class FirPropertyAccessExpressionImpl @FirImplementationDetail constructor( override var source: KtSourceElement?, override var nonFatalDiagnostics: MutableOrEmptyList, ) : FirPropertyAccessExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } calleeReference.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt index f38edd192f0..cbf4287b6a6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt @@ -30,6 +30,7 @@ internal class FirResolvedReifiedParameterReferenceImpl( override var annotations: MutableOrEmptyList, override val symbol: FirTypeParameterSymbol, ) : FirResolvedReifiedParameterReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt index 3a68b235b3f..9b704c6f956 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt @@ -30,6 +30,7 @@ internal class FirSafeCallExpressionImpl( override val checkedSubjectRef: FirExpressionRef, override var selector: FirStatement, ) : FirSafeCallExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } receiver.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt index b3da61d90fa..64ed15f83e8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt @@ -31,6 +31,7 @@ internal class FirTryExpressionImpl( override val catches: MutableList, override var finallyBlock: FirBlock?, ) : FirTryExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } calleeReference.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt index 6b710f67ef0..432ec031315 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt @@ -32,6 +32,7 @@ internal class FirVarargArgumentsExpressionImpl( override val arguments: MutableList, override var varargElementType: FirTypeRef, ) : FirVarargArgumentsExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } arguments.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt index 3c240e5b8ef..85f85fb08c5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt @@ -26,6 +26,7 @@ internal class FirVariableAssignmentImpl( override var lValue: FirExpression, override var rValue: FirExpression, ) : FirVariableAssignment() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } lValue.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt index 1ae2dc998db..86844879eaa 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt @@ -22,6 +22,7 @@ internal class FirWhenBranchImpl( override var condition: FirExpression, override var result: FirBlock, ) : FirWhenBranch() { + override fun acceptChildren(visitor: FirVisitor, data: D) { condition.accept(visitor, data) result.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt index ed19565cdb4..721a05ec1df 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt @@ -34,6 +34,7 @@ internal class FirWhenExpressionImpl( override var exhaustivenessStatus: ExhaustivenessStatus?, override val usedAsExpression: Boolean, ) : FirWhenExpression() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } calleeReference.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt index 9f7a0f7b976..7192574ae2d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt @@ -29,6 +29,7 @@ internal class FirWhileLoopImpl( override var condition: FirExpression, override var block: FirBlock, ) : FirWhileLoop() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } label?.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFileAnnotationsContainerImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFileAnnotationsContainerImpl.kt index 8c8d293f759..85e6720e459 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFileAnnotationsContainerImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFileAnnotationsContainerImpl.kt @@ -32,6 +32,7 @@ internal class FirFileAnnotationsContainerImpl( override var annotations: MutableOrEmptyList, override val containingFileSymbol: FirFileSymbol, ) : FirFileAnnotationsContainer() { + init { resolveState = resolvePhase.asResolveState() } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFunctionTypeParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFunctionTypeParameterImpl.kt index 3a11404bd41..6d769d99748 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFunctionTypeParameterImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirFunctionTypeParameterImpl.kt @@ -22,6 +22,7 @@ internal class FirFunctionTypeParameterImpl( override val name: Name?, override var returnTypeRef: FirTypeRef, ) : FirFunctionTypeParameter() { + override fun acceptChildren(visitor: FirVisitor, data: D) { returnTypeRef.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt index dcd381bb941..2b4f51ec83c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt @@ -19,6 +19,7 @@ internal class FirLabelImpl( override val source: KtSourceElement?, override val name: String, ) : FirLabel() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirLabelImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirPackageDirectiveImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirPackageDirectiveImpl.kt index 83522779c5d..0186f536abd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirPackageDirectiveImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirPackageDirectiveImpl.kt @@ -20,6 +20,7 @@ internal class FirPackageDirectiveImpl( override val source: KtSourceElement?, override val packageFqName: FqName, ) : FirPackageDirective() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirPackageDirectiveImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt index 1fe5b6270ae..114f77699a3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt @@ -21,6 +21,7 @@ internal class FirExplicitSuperReference( override val labelName: String?, override var superTypeRef: FirTypeRef, ) : FirSuperReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) { superTypeRef.accept(visitor, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirFromMissingDependenciesNamedReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirFromMissingDependenciesNamedReferenceImpl.kt index a510f70795e..2c70c364f96 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirFromMissingDependenciesNamedReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirFromMissingDependenciesNamedReferenceImpl.kt @@ -20,6 +20,7 @@ internal class FirFromMissingDependenciesNamedReferenceImpl( override val source: KtSourceElement?, override val name: Name, ) : FirFromMissingDependenciesNamedReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirFromMissingDependenciesNamedReferenceImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt index db7fa4d7ac7..bc09561ed34 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt @@ -23,6 +23,7 @@ class FirPropertyFromParameterResolvedNamedReference @FirImplementationDetail co override val name: Name, override val resolvedSymbol: FirBasedSymbol<*>, ) : FirResolvedNamedReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirPropertyFromParameterResolvedNamedReference { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt index 7c129943757..bb985723955 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt @@ -26,6 +26,7 @@ internal class FirResolvedCallableReferenceImpl( override val inferredTypeArguments: MutableList, override val mappedArguments: CallableReferenceMappedArguments, ) : FirResolvedCallableReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirResolvedCallableReferenceImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedErrorReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedErrorReferenceImpl.kt index bd48e573228..e9b51ef1ac0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedErrorReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedErrorReferenceImpl.kt @@ -24,6 +24,7 @@ internal class FirResolvedErrorReferenceImpl( override val resolvedSymbol: FirBasedSymbol<*>, override val diagnostic: ConeDiagnostic, ) : FirResolvedErrorReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirResolvedErrorReferenceImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt index 64469d330b0..b8a92d88544 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt @@ -22,6 +22,7 @@ internal class FirResolvedNamedReferenceImpl( override val name: Name, override val resolvedSymbol: FirBasedSymbol<*>, ) : FirResolvedNamedReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirResolvedNamedReferenceImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt index 705351394e1..570901716dd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt @@ -21,6 +21,7 @@ class FirSimpleNamedReference @FirImplementationDetail constructor( override val source: KtSourceElement?, override val name: Name, ) : FirNamedReference() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirSimpleNamedReference { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt index cf36a0e4834..02dc8ee89ea 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt @@ -24,6 +24,7 @@ internal class FirDynamicTypeRefImpl( override var annotations: MutableOrEmptyList, override val isMarkedNullable: Boolean, ) : FirDynamicTypeRef() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt index ccf8a5bf32c..3c05b2bbbb8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt @@ -31,6 +31,7 @@ internal class FirFunctionTypeRefImpl( override val isSuspend: Boolean, override val contextReceiverTypeRefs: MutableList, ) : FirFunctionTypeRef() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } receiverTypeRef?.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirIntersectionTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirIntersectionTypeRefImpl.kt index 35eed33e222..2203c4b6578 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirIntersectionTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirIntersectionTypeRefImpl.kt @@ -27,6 +27,7 @@ internal class FirIntersectionTypeRefImpl( override var leftType: FirTypeRef, override var rightType: FirTypeRef, ) : FirIntersectionTypeRef() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } leftType.accept(visitor, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirPlaceholderProjectionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirPlaceholderProjectionImpl.kt index 62a00fa24c5..b52fd1190ff 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirPlaceholderProjectionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirPlaceholderProjectionImpl.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor internal class FirPlaceholderProjectionImpl( override val source: KtSourceElement?, ) : FirPlaceholderProjection() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirPlaceholderProjectionImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt index c08908385e9..d0715f6d6d4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt @@ -28,6 +28,7 @@ class FirResolvedTypeRefImpl @FirImplementationDetail constructor( override val type: ConeKotlinType, override var delegatedTypeRef: FirTypeRef?, ) : FirResolvedTypeRef() { + override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt index a65f3770fa9..933e24b740c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor internal class FirStarProjectionImpl( override val source: KtSourceElement?, ) : FirStarProjection() { + override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirStarProjectionImpl { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt index 0222c9a37ce..c4255411a1f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt @@ -22,6 +22,7 @@ internal class FirTypeProjectionWithVarianceImpl( override var typeRef: FirTypeRef, override val variance: Variance, ) : FirTypeProjectionWithVariance() { + override fun acceptChildren(visitor: FirVisitor, data: D) { typeRef.accept(visitor, data) } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Element.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Element.kt index 1bb8b41b394..e8d171c9d88 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Element.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/Element.kt @@ -77,7 +77,7 @@ class Element(override val name: String, override val propertyName: String, kind get() = emptyList() // Use Implementation#transformableChildren instead var baseTransformerType: Element? = null - val transformerType: Element get() = baseTransformerType ?: this + val transformerClass: Element get() = baseTransformerType ?: this override val visitFunctionName: String get() = "visit$name" diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt index c0326df88b6..69e93a18356 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt @@ -13,140 +13,81 @@ import org.jetbrains.kotlin.fir.tree.generator.util.get import org.jetbrains.kotlin.generators.tree.* import org.jetbrains.kotlin.generators.tree.printer.* import org.jetbrains.kotlin.utils.SmartPrinter -import org.jetbrains.kotlin.utils.withIndent import java.io.File -fun Element.generateCode(generationPath: File): GeneratedFile = - printGeneratedType(generationPath, TREE_GENERATOR_README, packageName, this.typeName) { - println() - printElement(this@generateCode) - } +private class ElementPrinter(printer: SmartPrinter) : AbstractElementPrinter(printer) { -private class ElementFieldPrinter(printer: SmartPrinter) : AbstractFieldPrinter(printer) + override fun makeFieldPrinter(printer: SmartPrinter) = object : AbstractFieldPrinter(printer) {} -context(ImportCollector) -fun SmartPrinter.printElement(element: Element) { - with(element) { - val isInterface = kind == ImplementationKind.Interface || kind == ImplementationKind.SealedInterface - fun abstract() { - if (!isInterface) { - print("abstract ") - } - } + context(ImportCollector) + override fun SmartPrinter.printAdditionalMethods(element: Element) { + val kind = element.kind ?: error("Expected non-null element kind") + with(element) { + // TODO: Add a kDoc for `accept` + printAcceptMethod(element, firVisitorType, hasImplementation = true, kDoc = null) - fun override() { - if (!isRootElement) { - print("override ") - } - } - - printKDoc(element.extendedKDoc()) - print("${kind!!.title} $typeName") - print(params.typeParameters()) - val parentRefs = element.parentRefs - if (parentRefs.isNotEmpty()) { - print( - parentRefs.sortedBy { it.typeKind }.joinToString(prefix = " : ") { parent -> - parent.render() + parent.inheritanceClauseParenthesis() - } + // TODO: Add a kDoc for `transform` + printTransformMethod( + element = element, + transformerClass = firTransformerType, + implementation = "transformer.transform${element.name}(this, data)", + returnType = TypeVariable("E", listOf(AbstractFirTreeBuilder.baseFirElement)), + kDoc = null, ) - } - print(params.multipleUpperBoundsList()) - println(" {") - withIndent { - val fieldPrinter = ElementFieldPrinter(this@printElement) - allFields.forEach { field -> - if (field.isFinal && field.fromParent || field.isParameter) return@forEach - fieldPrinter.printField(field, override = field.fromParent) { - if (!field.isFinal) { - abstract() - } - } - } - - if (hasAcceptMethod) { - if (allFields.isNotEmpty()) { - println() - } - - override() - println("fun accept(visitor: ${firVisitorType.render()}, data: D): R =") - withIndent { - println("visitor.visit${element.name}(this, data)") - } - } - - if (hasTransformMethod) { - println() - println("@Suppress(\"UNCHECKED_CAST\")") - override() - println( - "fun transform(transformer: ", - firTransformerType.render(), - ", data: D): E =" - ) - withIndent { - println("transformer.transform$name(this, data) as E") - } - } fun Field.replaceDeclaration(override: Boolean, overridenType: TypeRefWithNullability? = null, forceNullable: Boolean = false) { println() if (name == "source") { - println("@${firImplementationDetailType.render()}") + println("@", firImplementationDetailType.render()) } - abstract() - if (override) print("override ") - println(replaceFunctionDeclaration(overridenType, forceNullable)) + replaceFunctionDeclaration(this, override, kind, overridenType, forceNullable) + println() } allFields.filter { it.withReplace }.forEach { - val override = overridenFields[it, it] && - !(it.name == "source" && element == FirTreeBuilder.qualifiedAccessExpression) + val override = overridenFields[it, it] && !(it.name == "source" && element == FirTreeBuilder.qualifiedAccessExpression) it.replaceDeclaration(override, forceNullable = it.useNullableForReplace) - for (overridenType in it.overridenTypes) { - it.replaceDeclaration(true, overridenType) + for (overriddenType in it.overridenTypes) { + it.replaceDeclaration(true, overriddenType) } } for (field in allFields) { if (!field.needsSeparateTransform) continue println() - abstract() - if (field.fromParent && field.parentHasSeparateTransform) { - print("override ") - } - println(field.transformFunctionDeclaration(element)) + transformFunctionDeclaration(field, element, override = field.fromParent && field.parentHasSeparateTransform, kind) + println() } if (needTransformOtherChildren) { println() - abstract() - if (element.elementParents.any { it.element.needTransformOtherChildren }) { - print("override ") - } - println(transformFunctionDeclaration("OtherChildren", element)) + transformOtherChildrenFunctionDeclaration( + element, + override = element.elementParents.any { it.element.needTransformOtherChildren }, + kind, + ) + println() } if (element.isRootElement) { - require(isInterface) { - "$element must be an interface" - } println() - println("fun accept(visitor: ${firVisitorVoidType.render()}) = accept(visitor, null)") - if (element.hasAcceptChildrenMethod) { - println() - println("fun acceptChildren(visitor: ${firVisitorType.render()}, data: D)") - } + println("fun accept(visitor: ", firVisitorVoidType.render(), ") = accept(visitor, null)") + + // TODO: Add a kDoc for `acceptChildren` + printAcceptChildrenMethod(element, firVisitorType, visitorResultType = TypeVariable("R"), kDoc = null) + println() + println() + println("fun acceptChildren(visitor: ", firVisitorVoidType.render(), ") = acceptChildren(visitor, null)") + + // TODO: Add a kDoc for `transformChildren` + printTransformChildrenMethod(element, firTransformerType, returnType = AbstractFirTreeBuilder.baseFirElement, kDoc = null) println() - println("fun acceptChildren(visitor: ${firVisitorVoidType.render()}) = acceptChildren(visitor, null)") - if (element.hasTransformChildrenMethod) { - println() - println("fun transformChildren(transformer: ${firTransformerType.render()}, data: D): FirElement") - } } } - println("}") } } + +fun Element.generateCode(generationPath: File): GeneratedFile = + printGeneratedType(generationPath, TREE_GENERATOR_README, packageName, typeName) { + println() + ElementPrinter(this).printElement(element) + } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt index 3d38ae1bd4c..1a6a641db40 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt @@ -9,10 +9,8 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.tree.generator.* import org.jetbrains.kotlin.fir.tree.generator.model.* import org.jetbrains.kotlin.generators.tree.* -import org.jetbrains.kotlin.generators.tree.printer.GeneratedFile +import org.jetbrains.kotlin.generators.tree.printer.* import org.jetbrains.kotlin.generators.tree.printer.braces -import org.jetbrains.kotlin.generators.tree.printer.printGeneratedType -import org.jetbrains.kotlin.generators.tree.printer.typeParameters import org.jetbrains.kotlin.utils.SmartPrinter import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty import org.jetbrains.kotlin.utils.withIndent @@ -86,12 +84,6 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { val isInterface = kind == ImplementationKind.Interface || kind == ImplementationKind.SealedInterface val isAbstract = kind == ImplementationKind.AbstractClass || kind == ImplementationKind.SealedClass - fun abstract() { - if (isAbstract) { - print("abstract ") - } - } - val fieldPrinter = ImplementationFieldPrinter(this@printImplementation) if (!isInterface && !isAbstract && fieldsWithoutDefault.isNotEmpty()) { @@ -128,9 +120,6 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { fieldsWithDefault.forEach { fieldPrinter.printField(it, override = true) } - if (fieldsWithDefault.isNotEmpty()) { - println() - } } @@ -146,6 +135,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { val customCalls = fieldsWithoutDefault.filter { it.customInitializationCall != null } if (bindingCalls.isNotEmpty() || customCalls.isNotEmpty()) { + println() println("init {") withIndent { for (symbolField in bindingCalls) { @@ -158,12 +148,13 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { } } println("}") - println() } fun Field.acceptString(): String = "${name}${call()}accept(visitor, data)" + if (hasAcceptChildrenMethod) { - print("override fun acceptChildren(visitor: ${firVisitorType.render()}, data: D) {") + printAcceptChildrenMethod(this, firVisitorType, TypeVariable("R"), override = true, kDoc = null) + print(" {") val walkableFields = walkableChildren if (walkableFields.isNotEmpty()) { @@ -223,16 +214,16 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { } } println("}") - println() } if (hasTransformChildrenMethod) { - abstract() - print( - "override fun transformChildren(transformer: ", - firTransformerType.render(), - ", data: D): ", - render(), + printTransformChildrenMethod( + this, + firTransformerType, + this, + modality = Modality.ABSTRACT.takeIf { isAbstract }, + override = true, + kDoc = null, ) if (!isInterface && !isAbstract) { println(" {") @@ -286,17 +277,15 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { } println("return this") } - println("}") - } else { - println() + print("}") } + println() } for (field in allFields) { if (!field.needsSeparateTransform) continue println() - abstract() - print("override ${field.transformFunctionDeclaration(this)}") + transformFunctionDeclaration(field, this, override = true, kind!!) if (isInterface || isAbstract) { println() continue @@ -327,13 +316,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { if (element.needTransformOtherChildren) { println() - abstract() - print( - "override fun transformOtherChildren(transformer: ", - firTransformerType.render(), - ", data: D): ", - render(), - ) + transformOtherChildrenFunctionDeclaration(this, override = true, kind!!) if (isInterface || isAbstract) { println() } else { @@ -364,8 +347,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) { if (field.name == "source") { println("@${firImplementationDetailType.render()}") } - abstract() - print("override ${field.replaceFunctionDeclaration(overridenType, forceNullable)}") + replaceFunctionDeclaration(field, override = true, kind!!, overridenType, forceNullable) if (isInterface || isAbstract) { println() return diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt index 0d3cf20b6d5..5eb476f34eb 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt @@ -37,7 +37,7 @@ private class TransformerPrinter( override val visitorDataType: TypeRef get() = dataTypeVariable - override fun visitMethodReturnType(element: Element) = element.transformerType + override fun visitMethodReturnType(element: Element) = element.transformerClass override val allowTypeParametersInVisitorMethods: Boolean get() = true diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt index ecd1b050f19..adf6fa7c76a 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt @@ -5,30 +5,77 @@ package org.jetbrains.kotlin.fir.tree.generator.printer +import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.tree.generator.firTransformerType import org.jetbrains.kotlin.fir.tree.generator.model.* import org.jetbrains.kotlin.generators.tree.* +import org.jetbrains.kotlin.generators.tree.printer.FunctionParameter +import org.jetbrains.kotlin.generators.tree.printer.printFunctionDeclaration +import org.jetbrains.kotlin.utils.SmartPrinter context(ImportCollector) -fun Field.transformFunctionDeclaration(returnType: TypeRef): String { - return transformFunctionDeclaration(name.replaceFirstChar(Char::uppercaseChar), returnType) +fun SmartPrinter.transformFunctionDeclaration( + field: Field, + returnType: TypeRef, + override: Boolean, + implementationKind: ImplementationKind, +) { + transformFunctionDeclaration(field.name.replaceFirstChar(Char::uppercaseChar), returnType, override, implementationKind) } context(ImportCollector) -fun transformFunctionDeclaration(transformName: String, returnType: TypeRef): String { - return "fun transform$transformName(transformer: ${firTransformerType.render()}, data: D): " + - returnType.render() +fun SmartPrinter.transformOtherChildrenFunctionDeclaration( + element: TypeRef, + override: Boolean, + implementationKind: ImplementationKind, +) { + transformFunctionDeclaration("OtherChildren", element, override, implementationKind) } context(ImportCollector) -fun Field.replaceFunctionDeclaration( - overridenType: TypeRefWithNullability? = null, +private fun SmartPrinter.transformFunctionDeclaration( + transformName: String, + returnType: TypeRef, + override: Boolean, + implementationKind: ImplementationKind, +) { + val dataTP = TypeVariable("D") + printFunctionDeclaration( + name = "transform$transformName", + parameters = listOf( + FunctionParameter("transformer", firTransformerType.withArgs(dataTP)), + FunctionParameter("data", dataTP), + ), + returnType = returnType, + typeParameters = listOf(dataTP), + modality = Modality.ABSTRACT.takeIf { + implementationKind == ImplementationKind.AbstractClass || implementationKind == ImplementationKind.SealedClass + }, + override = override, + ) +} + +context(ImportCollector) +fun SmartPrinter.replaceFunctionDeclaration( + field: Field, + override: Boolean, + implementationKind: ImplementationKind, + overriddenType: TypeRefWithNullability? = null, forceNullable: Boolean = false, -): String { - val capName = name.replaceFirstChar(Char::uppercaseChar) - val type = overridenType ?: typeRef +) { + val capName = field.name.replaceFirstChar(Char::uppercaseChar) + val type = overriddenType ?: field.typeRef val typeWithNullable = if (forceNullable) type.copy(nullable = true) else type - return "fun replace$capName(new$capName: ${typeWithNullable.render()})" + + printFunctionDeclaration( + name = "replace$capName", + parameters = listOf(FunctionParameter("new$capName", typeWithNullable)), + returnType = StandardTypes.unit, + modality = Modality.ABSTRACT.takeIf { + implementationKind == ImplementationKind.AbstractClass || implementationKind == ImplementationKind.SealedClass + }, + override = override, + ) } fun Field.getMutableType(forBuilder: Boolean = false): TypeRefWithNullability = when (this) { diff --git a/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/AbstractElementPrinter.kt b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/AbstractElementPrinter.kt new file mode 100644 index 00000000000..bdd8fcdf4e9 --- /dev/null +++ b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/AbstractElementPrinter.kt @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.generators.tree + +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.generators.tree.printer.* +import org.jetbrains.kotlin.utils.SmartPrinter +import org.jetbrains.kotlin.utils.withIndent + +/** + * A common class for printing FIR or IR tree elements. + */ +abstract class AbstractElementPrinter, Field : AbstractField>( + private val printer: SmartPrinter, +) { + + protected abstract fun makeFieldPrinter(printer: SmartPrinter): AbstractFieldPrinter + + context(ImportCollector) + protected abstract fun SmartPrinter.printAdditionalMethods(element: Element) + + protected open fun defaultElementKDoc(element: Element): String? = null + + protected open val separateFieldsWithBlankLine: Boolean + get() = false + + context(ImportCollector) + fun printElement(element: Element) { + printer.run { + val kind = element.kind ?: error("Expected non-null element kind") + + printKDoc(element.extendedKDoc(defaultElementKDoc(element))) + print(kind.title, " ", element.typeName) + print(element.params.typeParameters()) + + val parentRefs = element.parentRefs + if (parentRefs.isNotEmpty()) { + print( + parentRefs.sortedBy { it.typeKind }.joinToString(prefix = " : ") { parent -> + parent.render() + parent.inheritanceClauseParenthesis() + } + ) + } + print(element.params.multipleUpperBoundsList()) + + val body = SmartPrinter(StringBuilder()).apply { + val fieldPrinter = makeFieldPrinter(this) + withIndent { + for (field in element.allFields) { + if ( + !field.withGetter && field.defaultValueInImplementation == null && field.isFinal && field.fromParent || + field.isParameter + ) { + continue + } + if (separateFieldsWithBlankLine) println() + fieldPrinter.printField( + field, + override = field.fromParent, + modality = Modality.ABSTRACT.takeIf { !field.isFinal && !kind.isInterface }, + ) + } + printAdditionalMethods(element) + } + }.toString() + + if (body.isNotEmpty()) { + println(" {") + print(body) + print("}") + } + println() + } + } +} diff --git a/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/printer/printUtils.kt b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/printer/printUtils.kt index 82f5ad02ceb..a838ab7d6d5 100644 --- a/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/printer/printUtils.kt +++ b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/printer/printUtils.kt @@ -146,4 +146,120 @@ fun SmartPrinter.printFunctionDeclaration( print(": ", returnType.render()) } print(typeParameters.multipleUpperBoundsList()) -} \ No newline at end of file +} + +private val dataTP = TypeVariable("D") +private val dataParameter = FunctionParameter("data", dataTP) + +context(ImportCollector) +fun SmartPrinter.printAcceptMethod( + element: AbstractElement<*, *>, + visitorClass: ClassRef, + hasImplementation: Boolean, + kDoc: String?, +) { + if (!element.hasAcceptMethod) return + println() + printKDoc(kDoc) + val resultTP = TypeVariable("R") + printFunctionDeclaration( + name = "accept", + parameters = listOf( + FunctionParameter("visitor", visitorClass.withArgs(resultTP, dataTP)), + dataParameter, + ), + returnType = resultTP, + typeParameters = listOf(resultTP, dataTP), + override = !element.isRootElement, + ) + if (hasImplementation) { + println(" =") + withIndent { + print("visitor.", element.visitFunctionName, "(this, ", dataParameter.name, ")") + } + } + println() +} + +context(ImportCollector) +fun SmartPrinter.printTransformMethod( + element: AbstractElement<*, *>, + transformerClass: ClassRef, + implementation: String?, + returnType: TypeRefWithNullability, + kDoc: String?, +) { + if (!element.hasTransformMethod) return + println() + printKDoc(kDoc) + if (returnType is TypeParameterRef && implementation != null) { + println("@Suppress(\"UNCHECKED_CAST\")") + } + printFunctionDeclaration( + name = "transform", + parameters = listOf( + FunctionParameter("transformer", transformerClass.withArgs(dataTP)), + dataParameter, + ), + returnType = returnType, + typeParameters = listOfNotNull(returnType as? TypeVariable, dataTP), + override = !element.isRootElement, + ) + if (implementation != null) { + println(" =") + withIndent { + print(implementation, " as ", returnType.render()) + } + } + println() +} + +context(ImportCollector) +fun SmartPrinter.printAcceptChildrenMethod( + element: FieldContainer, + visitorClass: ClassRef, + visitorResultType: TypeRef, + modality: Modality? = null, + override: Boolean = false, + kDoc: String?, +) { + if (!element.hasAcceptChildrenMethod) return + println() + printKDoc(kDoc) + printFunctionDeclaration( + name = "acceptChildren", + parameters = listOf( + FunctionParameter("visitor", visitorClass.withArgs(visitorResultType, dataTP)), + dataParameter, + ), + returnType = StandardTypes.unit, + typeParameters = listOfNotNull(visitorResultType as? TypeVariable, dataTP), + modality = modality, + override = override, + ) +} + +context(ImportCollector) +fun SmartPrinter.printTransformChildrenMethod( + element: FieldContainer, + transformerClass: ClassRef, + returnType: TypeRef, + modality: Modality? = null, + override: Boolean = false, + kDoc: String?, +) { + if (!element.hasTransformChildrenMethod) return + println() + printKDoc(kDoc) + printFunctionDeclaration( + name = "transformChildren", + parameters = listOf( + FunctionParameter("transformer", transformerClass.withArgs(dataTP)), + dataParameter, + ), + returnType = returnType, + typeParameters = listOf(dataTP), + modality = modality, + override = override, + ) +}