[FIR] Add transformContextReceivers() method to FirProperty
This commit is contained in:
committed by
teamcity
parent
f3fc5cbc42
commit
7ef2f7ccde
@@ -36,7 +36,6 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
|
||||
abstract override val deprecationsProvider: DeprecationsProvider
|
||||
abstract override val containerSource: DeserializedContainerSource?
|
||||
abstract override val dispatchReceiverType: ConeSimpleKotlinType?
|
||||
abstract override val contextReceivers: List<FirContextReceiver>
|
||||
abstract override val name: Name
|
||||
abstract override val initializer: FirExpression?
|
||||
abstract override val delegate: FirExpression?
|
||||
@@ -47,6 +46,7 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
|
||||
abstract override val backingField: FirBackingField?
|
||||
abstract override val annotations: List<FirAnnotation>
|
||||
abstract override val controlFlowGraphReference: FirControlFlowGraphReference?
|
||||
abstract override val contextReceivers: List<FirContextReceiver>
|
||||
abstract override val symbol: FirPropertySymbol
|
||||
abstract val delegateFieldSymbol: FirDelegateFieldSymbol?
|
||||
abstract val isLocal: Boolean
|
||||
@@ -67,8 +67,6 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
|
||||
|
||||
abstract override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider)
|
||||
|
||||
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
|
||||
|
||||
abstract override fun replaceInitializer(newInitializer: FirExpression?)
|
||||
|
||||
abstract override fun replaceGetter(newGetter: FirPropertyAccessor?)
|
||||
@@ -77,6 +75,8 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
|
||||
|
||||
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
|
||||
|
||||
abstract override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>)
|
||||
|
||||
abstract fun replaceBodyResolveState(newBodyResolveState: FirPropertyBodyResolveState)
|
||||
|
||||
abstract override fun <D> transformStatus(transformer: FirTransformer<D>, data: D): FirProperty
|
||||
@@ -97,6 +97,8 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
|
||||
|
||||
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirProperty
|
||||
|
||||
abstract fun <D> transformContextReceivers(transformer: FirTransformer<D>, data: D): FirProperty
|
||||
|
||||
abstract override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirProperty
|
||||
|
||||
abstract override fun <D> transformOtherChildren(transformer: FirTransformer<D>, data: D): FirProperty
|
||||
|
||||
+3
-3
@@ -57,7 +57,6 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder,
|
||||
var deprecationsProvider: DeprecationsProvider = UnresolvedDeprecationProvider
|
||||
var containerSource: DeserializedContainerSource? = null
|
||||
var dispatchReceiverType: ConeSimpleKotlinType? = null
|
||||
val contextReceivers: MutableList<FirContextReceiver> = mutableListOf()
|
||||
lateinit var name: Name
|
||||
var initializer: FirExpression? = null
|
||||
var delegate: FirExpression? = null
|
||||
@@ -66,6 +65,7 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder,
|
||||
var setter: FirPropertyAccessor? = null
|
||||
var backingField: FirBackingField? = null
|
||||
override val annotations: MutableList<FirAnnotation> = mutableListOf()
|
||||
val contextReceivers: MutableList<FirContextReceiver> = mutableListOf()
|
||||
lateinit var symbol: FirPropertySymbol
|
||||
var delegateFieldSymbol: FirDelegateFieldSymbol? = null
|
||||
var isLocal: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
|
||||
@@ -85,7 +85,6 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder,
|
||||
deprecationsProvider,
|
||||
containerSource,
|
||||
dispatchReceiverType,
|
||||
contextReceivers,
|
||||
name,
|
||||
initializer,
|
||||
delegate,
|
||||
@@ -94,6 +93,7 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder,
|
||||
setter,
|
||||
backingField,
|
||||
annotations,
|
||||
contextReceivers,
|
||||
symbol,
|
||||
delegateFieldSymbol,
|
||||
isLocal,
|
||||
@@ -129,7 +129,6 @@ inline fun buildPropertyCopy(original: FirProperty, init: FirPropertyBuilder.()
|
||||
copyBuilder.deprecationsProvider = original.deprecationsProvider
|
||||
copyBuilder.containerSource = original.containerSource
|
||||
copyBuilder.dispatchReceiverType = original.dispatchReceiverType
|
||||
copyBuilder.contextReceivers.addAll(original.contextReceivers)
|
||||
copyBuilder.name = original.name
|
||||
copyBuilder.initializer = original.initializer
|
||||
copyBuilder.delegate = original.delegate
|
||||
@@ -138,6 +137,7 @@ inline fun buildPropertyCopy(original: FirProperty, init: FirPropertyBuilder.()
|
||||
copyBuilder.setter = original.setter
|
||||
copyBuilder.backingField = original.backingField
|
||||
copyBuilder.annotations.addAll(original.annotations)
|
||||
copyBuilder.contextReceivers.addAll(original.contextReceivers)
|
||||
copyBuilder.symbol = original.symbol
|
||||
copyBuilder.delegateFieldSymbol = original.delegateFieldSymbol
|
||||
copyBuilder.isLocal = original.isLocal
|
||||
|
||||
+13
-8
@@ -50,7 +50,6 @@ internal class FirPropertyImpl(
|
||||
override var deprecationsProvider: DeprecationsProvider,
|
||||
override val containerSource: DeserializedContainerSource?,
|
||||
override val dispatchReceiverType: ConeSimpleKotlinType?,
|
||||
override val contextReceivers: MutableList<FirContextReceiver>,
|
||||
override val name: Name,
|
||||
override var initializer: FirExpression?,
|
||||
override var delegate: FirExpression?,
|
||||
@@ -59,6 +58,7 @@ internal class FirPropertyImpl(
|
||||
override var setter: FirPropertyAccessor?,
|
||||
override var backingField: FirBackingField?,
|
||||
override val annotations: MutableList<FirAnnotation>,
|
||||
override val contextReceivers: MutableList<FirContextReceiver>,
|
||||
override val symbol: FirPropertySymbol,
|
||||
override val delegateFieldSymbol: FirDelegateFieldSymbol?,
|
||||
override val isLocal: Boolean,
|
||||
@@ -77,7 +77,6 @@ internal class FirPropertyImpl(
|
||||
status.accept(visitor, data)
|
||||
returnTypeRef.accept(visitor, data)
|
||||
receiverTypeRef?.accept(visitor, data)
|
||||
contextReceivers.forEach { it.accept(visitor, data) }
|
||||
initializer?.accept(visitor, data)
|
||||
delegate?.accept(visitor, data)
|
||||
getter?.accept(visitor, data)
|
||||
@@ -85,6 +84,7 @@ internal class FirPropertyImpl(
|
||||
backingField?.accept(visitor, data)
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
controlFlowGraphReference?.accept(visitor, data)
|
||||
contextReceivers.forEach { it.accept(visitor, data) }
|
||||
typeParameters.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ internal class FirPropertyImpl(
|
||||
transformGetter(transformer, data)
|
||||
transformSetter(transformer, data)
|
||||
transformBackingField(transformer, data)
|
||||
transformContextReceivers(transformer, data)
|
||||
transformTypeParameters(transformer, data)
|
||||
transformOtherChildren(transformer, data)
|
||||
return this
|
||||
@@ -147,13 +148,17 @@ internal class FirPropertyImpl(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformContextReceivers(transformer: FirTransformer<D>, data: D): FirPropertyImpl {
|
||||
contextReceivers.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirPropertyImpl {
|
||||
typeParameters.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformOtherChildren(transformer: FirTransformer<D>, data: D): FirPropertyImpl {
|
||||
contextReceivers.transformInplace(transformer, data)
|
||||
transformAnnotations(transformer, data)
|
||||
controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data)
|
||||
return this
|
||||
@@ -175,11 +180,6 @@ internal class FirPropertyImpl(
|
||||
deprecationsProvider = newDeprecationsProvider
|
||||
}
|
||||
|
||||
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
|
||||
contextReceivers.clear()
|
||||
contextReceivers.addAll(newContextReceivers)
|
||||
}
|
||||
|
||||
override fun replaceInitializer(newInitializer: FirExpression?) {
|
||||
initializer = newInitializer
|
||||
}
|
||||
@@ -196,6 +196,11 @@ internal class FirPropertyImpl(
|
||||
controlFlowGraphReference = newControlFlowGraphReference
|
||||
}
|
||||
|
||||
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
|
||||
contextReceivers.clear()
|
||||
contextReceivers.addAll(newContextReceivers)
|
||||
}
|
||||
|
||||
override fun replaceBodyResolveState(newBodyResolveState: FirPropertyBodyResolveState) {
|
||||
bodyResolveState = newBodyResolveState
|
||||
}
|
||||
|
||||
+17
-9
@@ -138,43 +138,51 @@ class FirSyntheticProperty(
|
||||
throw AssertionError("Transformation of synthetic property isn't supported")
|
||||
}
|
||||
|
||||
override fun <D> transformContextReceivers(transformer: FirTransformer<D>, data: D): FirProperty {
|
||||
throw AssertionError("Transformation of synthetic property isn't supported")
|
||||
}
|
||||
|
||||
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) {
|
||||
resolvePhase = newResolvePhase
|
||||
}
|
||||
|
||||
override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceReceiverTypeRef(newReceiverTypeRef: FirTypeRef?) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceDeprecationsProvider(newDeprecationsProvider: DeprecationsProvider) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceInitializer(newInitializer: FirExpression?) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceBodyResolveState(newBodyResolveState: FirPropertyBodyResolveState) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceGetter(newGetter: FirPropertyAccessor?) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceSetter(newSetter: FirPropertyAccessor?) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
override fun replaceContextReceivers(newContextReceivers: List<FirContextReceiver>) {
|
||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||
notSupported()
|
||||
}
|
||||
|
||||
private fun notSupported(): Nothing {
|
||||
throw AssertionError("Transformation of synthetic property isn't supported")
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -325,6 +325,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
}
|
||||
|
||||
property.configure {
|
||||
+fieldList(contextReceiver, withReplace = true).withTransform()
|
||||
+symbol("FirPropertySymbol")
|
||||
+field("delegateFieldSymbol", delegateFieldSymbolType, nullable = true)
|
||||
+booleanField("isLocal")
|
||||
|
||||
+1
@@ -102,6 +102,7 @@ class Element(override val name: String, kind: Kind) : AbstractElement {
|
||||
existingField.needsSeparateTransform = existingField.needsSeparateTransform || parentField.needsSeparateTransform
|
||||
existingField.needTransformInOtherChildren = existingField.needTransformInOtherChildren || parentField.needTransformInOtherChildren
|
||||
existingField.withReplace = parentField.withReplace || existingField.withReplace
|
||||
existingField.parentHasSeparateTransform = parentField.needsSeparateTransform
|
||||
if (parentField.type != existingField.type && parentField.withReplace) {
|
||||
existingField.overridenTypes += parentField
|
||||
overridenFields[existingField, parentField] = false
|
||||
|
||||
+2
@@ -17,6 +17,7 @@ sealed class Field : Importable {
|
||||
|
||||
var fromParent: Boolean = false
|
||||
open var needsSeparateTransform: Boolean = false
|
||||
var parentHasSeparateTransform: Boolean = true
|
||||
open var needTransformInOtherChildren: Boolean = false
|
||||
|
||||
open val defaultValueInImplementation: String? get() = null
|
||||
@@ -46,6 +47,7 @@ sealed class Field : Importable {
|
||||
copy.useNullableForReplace = useNullableForReplace
|
||||
}
|
||||
copy.fromParent = fromParent
|
||||
copy.parentHasSeparateTransform = parentHasSeparateTransform
|
||||
}
|
||||
|
||||
protected abstract fun internalCopy(): Field
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ fun SmartPrinter.printElement(element: Element) {
|
||||
if (!field.needsSeparateTransform) continue
|
||||
println()
|
||||
abstract()
|
||||
if (field.fromParent) {
|
||||
if (field.fromParent && field.parentHasSeparateTransform) {
|
||||
print("override ")
|
||||
}
|
||||
println(field.transformFunctionDeclaration(typeWithArguments))
|
||||
|
||||
Reference in New Issue
Block a user