From 8ce28cb50914a96a2d03d39b79a8793589718b79 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Sun, 21 Jun 2020 13:06:20 +0300 Subject: [PATCH] [FIR] Add `transformBody` to `FirFunction` --- .../kotlin/fir/java/declarations/FirJavaConstructor.kt | 4 ++++ .../kotlin/fir/declarations/FirAnonymousFunction.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirConstructor.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirErrorFunction.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirFunction.kt | 2 ++ .../kotlin/fir/declarations/FirPropertyAccessor.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt | 2 ++ .../fir/declarations/impl/FirAnonymousFunctionImpl.kt | 7 ++++++- .../kotlin/fir/declarations/impl/FirConstructorImpl.kt | 7 ++++++- .../kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt | 4 ++++ .../kotlin/fir/declarations/impl/FirPrimaryConstructor.kt | 7 ++++++- .../fir/declarations/impl/FirPropertyAccessorImpl.kt | 7 ++++++- .../kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt | 7 ++++++- .../declarations/synthetic/FirSyntheticPropertyAccessor.kt | 4 ++++ .../kotlin/fir/tree/generator/NodeConfigurator.kt | 2 +- 15 files changed, 55 insertions(+), 6 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt index 23fc2c5f640..f47570f8d94 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt @@ -113,6 +113,10 @@ class FirJavaConstructor @FirImplementationDetail constructor( return this } + override fun transformBody(transformer: FirTransformer, data: D): FirConstructor { + return this + } + override var containerSource: DeserializedContainerSource? = null override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt index 54925c1ead6..02844d40038 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt @@ -64,4 +64,6 @@ abstract class FirAnonymousFunction : FirFunction, FirExpr abstract override fun transformControlFlowGraphReference(transformer: FirTransformer, data: D): FirAnonymousFunction abstract override fun transformValueParameters(transformer: FirTransformer, data: D): FirAnonymousFunction + + abstract override fun transformBody(transformer: FirTransformer, data: D): FirAnonymousFunction } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt index 32f712d6309..080e555a182 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt @@ -64,4 +64,6 @@ abstract class FirConstructor : FirPureAbstractElement(), FirFunction transformAnnotations(transformer: FirTransformer, data: D): FirConstructor abstract fun transformDelegatedConstructor(transformer: FirTransformer, data: D): FirConstructor + + abstract override fun transformBody(transformer: FirTransformer, data: D): FirConstructor } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt index 70dc21560f9..394ff910aaa 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt @@ -57,4 +57,6 @@ abstract class FirErrorFunction : FirPureAbstractElement(), FirFunction transformControlFlowGraphReference(transformer: FirTransformer, data: D): FirErrorFunction abstract override fun transformValueParameters(transformer: FirTransformer, data: D): FirErrorFunction + + abstract override fun transformBody(transformer: FirTransformer, data: D): FirErrorFunction } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt index 10035a87538..12d3bb23f5c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt @@ -55,4 +55,6 @@ interface FirFunction> : FirCallableDeclaration, FirTarget override fun transformControlFlowGraphReference(transformer: FirTransformer, data: D): FirFunction fun transformValueParameters(transformer: FirTransformer, data: D): FirFunction + + fun transformBody(transformer: FirTransformer, data: D): FirFunction } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt index aa6105d75e1..f67068795ff 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt @@ -60,6 +60,8 @@ abstract class FirPropertyAccessor : FirPureAbstractElement(), FirFunction transformValueParameters(transformer: FirTransformer, data: D): FirPropertyAccessor + abstract override fun transformBody(transformer: FirTransformer, data: D): FirPropertyAccessor + abstract override fun transformContractDescription(transformer: FirTransformer, data: D): FirPropertyAccessor abstract fun transformStatus(transformer: FirTransformer, data: D): FirPropertyAccessor diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt index 4bdc9415e61..da62556704a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt @@ -62,6 +62,8 @@ abstract class FirSimpleFunction : FirPureAbstractElement(), FirFunction transformValueParameters(transformer: FirTransformer, data: D): FirSimpleFunction + abstract override fun transformBody(transformer: FirTransformer, data: D): FirSimpleFunction + abstract override fun transformStatus(transformer: FirTransformer, data: D): FirSimpleFunction abstract override fun transformContractDescription(transformer: FirTransformer, data: D): FirSimpleFunction 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 e378448bf00..a30e73ab89b 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 @@ -69,7 +69,7 @@ internal class FirAnonymousFunctionImpl( transformReceiverTypeRef(transformer, data) transformControlFlowGraphReference(transformer, data) transformValueParameters(transformer, data) - body = body?.transformSingle(transformer, data) + transformBody(transformer, data) typeRef = typeRef.transformSingle(transformer, data) label = label?.transformSingle(transformer, data) typeParameters.transformInplace(transformer, data) @@ -101,6 +101,11 @@ internal class FirAnonymousFunctionImpl( return this } + override fun transformBody(transformer: FirTransformer, data: D): FirAnonymousFunctionImpl { + body = body?.transformSingle(transformer, data) + return this + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt index 1109d07b540..cc48afa2c45 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt @@ -74,7 +74,7 @@ internal class FirConstructorImpl( transformStatus(transformer, data) transformAnnotations(transformer, data) transformDelegatedConstructor(transformer, data) - body = body?.transformSingle(transformer, data) + transformBody(transformer, data) return this } @@ -113,6 +113,11 @@ internal class FirConstructorImpl( return this } + override fun transformBody(transformer: FirTransformer, data: D): FirConstructorImpl { + body = body?.transformSingle(transformer, data) + return this + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt index 8c423c79b56..0969ee4b728 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt @@ -90,6 +90,10 @@ internal class FirErrorFunctionImpl( return this } + override fun transformBody(transformer: FirTransformer, data: D): FirErrorFunctionImpl { + return this + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt index b7db76ab31e..4ae96602182 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt @@ -74,7 +74,7 @@ internal class FirPrimaryConstructor( transformStatus(transformer, data) transformAnnotations(transformer, data) transformDelegatedConstructor(transformer, data) - body = body?.transformSingle(transformer, data) + transformBody(transformer, data) return this } @@ -113,6 +113,11 @@ internal class FirPrimaryConstructor( return this } + override fun transformBody(transformer: FirTransformer, data: D): FirPrimaryConstructor { + body = body?.transformSingle(transformer, data) + return this + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt index 54fff6e213d..1a341b8eda7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt @@ -69,7 +69,7 @@ open class FirPropertyAccessorImpl @FirImplementationDetail constructor( transformReturnTypeRef(transformer, data) transformControlFlowGraphReference(transformer, data) transformValueParameters(transformer, data) - body = body?.transformSingle(transformer, data) + transformBody(transformer, data) transformContractDescription(transformer, data) transformStatus(transformer, data) transformAnnotations(transformer, data) @@ -96,6 +96,11 @@ open class FirPropertyAccessorImpl @FirImplementationDetail constructor( return this } + override fun transformBody(transformer: FirTransformer, data: D): FirPropertyAccessorImpl { + body = body?.transformSingle(transformer, data) + return this + } + override fun transformContractDescription(transformer: FirTransformer, data: D): FirPropertyAccessorImpl { contractDescription = contractDescription.transformSingle(transformer, data) return this diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt index 51c93d92d08..b06b2e4f42d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt @@ -72,7 +72,7 @@ open class FirSimpleFunctionImpl @FirImplementationDetail constructor( transformReceiverTypeRef(transformer, data) transformControlFlowGraphReference(transformer, data) transformValueParameters(transformer, data) - body = body?.transformSingle(transformer, data) + transformBody(transformer, data) transformStatus(transformer, data) transformContractDescription(transformer, data) transformAnnotations(transformer, data) @@ -100,6 +100,11 @@ open class FirSimpleFunctionImpl @FirImplementationDetail constructor( return this } + override fun transformBody(transformer: FirTransformer, data: D): FirSimpleFunctionImpl { + body = body?.transformSingle(transformer, data) + return this + } + override fun transformStatus(transformer: FirTransformer, data: D): FirSimpleFunctionImpl { status = status.transformSingle(transformer, data) return this diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt index 9089fc755af..341d845f3e2 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt @@ -109,6 +109,10 @@ class FirSyntheticPropertyAccessor( throw AssertionError("Transformation of synthetic property accessor isn't supported") } + override fun transformBody(transformer: FirTransformer, data: D): FirPropertyAccessor { + throw AssertionError("Transformation of synthetic property accessor isn't supported") + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { throw AssertionError("Mutation of synthetic property accessor isn't supported") } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index 187d462b6a2..d1a3c93084f 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -103,7 +103,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild parentArg(callableDeclaration, "F", "F") +symbol("FirFunctionSymbol", "F") +fieldList(valueParameter, withReplace = true).withTransform() - +body(nullable = true) + +body(nullable = true).withTransform() } errorFunction.configure {