FIR: Add replaceContextReceivers to FirCallableDeclaration

This commit is contained in:
Denis.Zharkov
2022-02-25 11:38:26 +03:00
committed by teamcity
parent 8f013db94d
commit 90b12433ec
34 changed files with 118 additions and 1 deletions
@@ -140,6 +140,10 @@ class FirJavaConstructor @FirImplementationDetail constructor(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
error("Context receivers cannot be replaced for FirJavaConstructor")
}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {}
override fun replaceBody(newBody: FirBlock?) {
@@ -159,6 +159,10 @@ class FirJavaField @FirImplementationDetail constructor(
override fun replaceSetter(newSetter: FirPropertyAccessor?) {}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
error("Body cannot be replaced for FirJavaField")
}
}
@FirBuilderDsl
@@ -181,6 +181,10 @@ class FirJavaMethod @FirImplementationDetail constructor(
override fun replaceContractDescription(newContractDescription: FirContractDescription) {
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
error("Body cannot be replaced for FirJavaMethod")
}
}
val ALL_JAVA_OPERATION_NAMES =
@@ -184,6 +184,10 @@ class FirJavaValueParameter @FirImplementationDetail constructor(
override fun replaceSetter(newSetter: FirPropertyAccessor?) {
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
error("Body cannot be replaced for FirJavaValueParameter")
}
}
@FirBuilderDsl
@@ -64,6 +64,8 @@ abstract class FirAnonymousFunction : FirFunction(), FirTypeParametersOwner {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract override fun replaceValueParameters(newValueParameters: List<FirValueParameter>)
@@ -64,6 +64,8 @@ abstract class FirBackingField : FirVariable(), FirTypeParametersOwner, FirState
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceGetter(newGetter: FirPropertyAccessor?)
abstract override fun replaceSetter(newSetter: FirPropertyAccessor?)
@@ -51,6 +51,8 @@ sealed class FirCallableDeclaration : FirMemberDeclaration() {
abstract fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirCallableDeclaration
abstract override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirCallableDeclaration
@@ -59,6 +59,8 @@ abstract class FirConstructor : FirFunction(), FirTypeParameterRefsOwner {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract override fun replaceValueParameters(newValueParameters: List<FirValueParameter>)
@@ -61,6 +61,8 @@ abstract class FirEnumEntry : FirVariable() {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceInitializer(newInitializer: FirExpression?)
abstract override fun replaceGetter(newGetter: FirPropertyAccessor?)
@@ -59,6 +59,8 @@ abstract class FirErrorFunction : FirFunction(), FirDiagnosticHolder {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract override fun replaceValueParameters(newValueParameters: List<FirValueParameter>)
@@ -64,6 +64,8 @@ abstract class FirErrorProperty : FirVariable(), FirDiagnosticHolder {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceInitializer(newInitializer: FirExpression?)
abstract override fun replaceGetter(newGetter: FirPropertyAccessor?)
@@ -63,6 +63,8 @@ abstract class FirField : FirVariable(), FirControlFlowGraphOwner {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceInitializer(newInitializer: FirExpression?)
abstract override fun replaceGetter(newGetter: FirPropertyAccessor?)
@@ -58,6 +58,8 @@ sealed class FirFunction : FirCallableDeclaration(), FirTargetElement, FirContro
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract fun replaceValueParameters(newValueParameters: List<FirValueParameter>)
@@ -67,6 +67,8 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceInitializer(newInitializer: FirExpression?)
abstract override fun replaceGetter(newGetter: FirPropertyAccessor?)
@@ -62,6 +62,8 @@ abstract class FirPropertyAccessor : FirFunction(), FirContractDescriptionOwner,
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract override fun replaceValueParameters(newValueParameters: List<FirValueParameter>)
@@ -60,6 +60,8 @@ abstract class FirSimpleFunction : FirFunction(), FirContractDescriptionOwner, F
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract override fun replaceValueParameters(newValueParameters: List<FirValueParameter>)
@@ -67,6 +67,8 @@ abstract class FirValueParameter : FirVariable(), FirControlFlowGraphOwner {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract override fun replaceInitializer(newInitializer: FirExpression?)
abstract override fun replaceGetter(newGetter: FirPropertyAccessor?)
@@ -62,6 +62,8 @@ sealed class FirVariable : FirCallableDeclaration(), FirStatement {
abstract override fun replaceDeprecation(newDeprecation: DeprecationsPerUseSite?)
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
abstract fun replaceInitializer(newInitializer: FirExpression?)
abstract fun replaceGetter(newGetter: FirPropertyAccessor?)
@@ -146,6 +146,11 @@ internal class FirAnonymousFunctionImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference
}
@@ -163,6 +163,11 @@ open class FirBackingFieldImpl @FirImplementationDetail constructor(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceGetter(newGetter: FirPropertyAccessor?) {
getter = newGetter
}
@@ -142,6 +142,11 @@ internal class FirConstructorImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference
}
@@ -170,6 +170,11 @@ internal class FirDefaultSetterValueParameter(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceInitializer(newInitializer: FirExpression?) {
initializer = newInitializer
}
@@ -148,6 +148,11 @@ internal class FirEnumEntryImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceInitializer(newInitializer: FirExpression?) {
initializer = newInitializer
}
@@ -125,6 +125,11 @@ internal class FirErrorFunctionImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference
}
@@ -146,6 +146,11 @@ internal class FirErrorPropertyImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceInitializer(newInitializer: FirExpression?) {}
override fun replaceGetter(newGetter: FirPropertyAccessor?) {}
@@ -153,6 +153,11 @@ class FirFieldImpl @FirImplementationDetail constructor(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceInitializer(newInitializer: FirExpression?) {
initializer = newInitializer
}
@@ -143,6 +143,11 @@ class FirPrimaryConstructor @FirImplementationDetail constructor(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference
}
@@ -142,6 +142,11 @@ open class FirPropertyAccessorImpl @FirImplementationDetail constructor(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference
}
@@ -173,6 +173,11 @@ internal class FirPropertyImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceInitializer(newInitializer: FirExpression?) {
initializer = newInitializer
}
@@ -143,6 +143,11 @@ internal class FirSimpleFunctionImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference
}
@@ -153,6 +153,11 @@ internal class FirValueParameterImpl(
deprecation = newDeprecation
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
contextReceivers.clear()
contextReceivers.addAll(newContextReceivers)
}
override fun replaceInitializer(newInitializer: FirExpression?) {}
override fun replaceGetter(newGetter: FirPropertyAccessor?) {}
@@ -173,4 +173,8 @@ class FirSyntheticProperty(
override fun replaceSetter(newSetter: FirPropertyAccessor?) {
throw AssertionError("Mutation of synthetic property isn't supported")
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
throw AssertionError("Mutation of synthetic property isn't supported")
}
}
@@ -160,4 +160,8 @@ class FirSyntheticPropertyAccessor(
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
throw AssertionError("Mutation of synthetic property accessor isn't supported")
}
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
throw AssertionError("Mutation of synthetic property accessor isn't supported")
}
}
@@ -94,7 +94,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
+field("containerSource", type(DeserializedContainerSource::class), nullable = true)
+field("dispatchReceiverType", coneSimpleKotlinTypeType, nullable = true)
+fieldList(contextReceiver)
+fieldList(contextReceiver, withReplace = true)
}
function.configure {