Skip to content

Commit 81dd7cf

Browse files
mcpiromanSpace Team
authored andcommitted
[IR] Rename IrAttribute.followAttributeOwner to copyByDefault
It better describes the current semantics. KT-74331
1 parent e14a947 commit 81dd7cf

File tree

48 files changed

+111
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+111
-122
lines changed

compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ private object IsStubPropertyForPureFieldKey : FirDeclarationDataKey()
14611461

14621462
internal var FirProperty.isStubPropertyForPureField: Boolean? by FirDeclarationDataRegistry.data(IsStubPropertyForPureFieldKey)
14631463

1464-
internal var IrClass.isNonCachedSourceFileFacade: Boolean by irFlag(followAttributeOwner = false)
1464+
internal var IrClass.isNonCachedSourceFileFacade: Boolean by irFlag(copyByDefault = false)
14651465

14661466
/**
14671467
* Opt-in to this annotation indicates that some code uses annotated function but it actually shouldn't

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,25 @@ import org.jetbrains.kotlin.ir.get
1111
import org.jetbrains.kotlin.ir.irAttribute
1212
import org.jetbrains.kotlin.ir.set
1313
import java.util.concurrent.ConcurrentHashMap
14-
import kotlin.reflect.KMutableProperty0
1514
import kotlin.reflect.KProperty
1615

17-
var IrFunction.defaultArgumentsDispatchFunction: IrFunction? by irAttribute(followAttributeOwner = false)
16+
var IrFunction.defaultArgumentsDispatchFunction: IrFunction? by irAttribute(copyByDefault = false)
1817

19-
var IrClass.capturedFields: Collection<IrField>? by irAttribute(followAttributeOwner = false)
18+
var IrClass.capturedFields: Collection<IrField>? by irAttribute(copyByDefault = false)
2019

21-
var IrClass.reflectedNameAccessor: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
20+
var IrClass.reflectedNameAccessor: IrSimpleFunction? by irAttribute(copyByDefault = false)
2221

2322
/**
2423
* If this is a `suspend` function, returns its corresponding function with continuations.
2524
*/
26-
var IrSimpleFunction.functionWithContinuations: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
25+
var IrSimpleFunction.functionWithContinuations: IrSimpleFunction? by irAttribute(copyByDefault = false)
2726

2827
/**
2928
* If this is a function with continuation, returns its corresponding `suspend` function.
3029
*/
31-
var IrSimpleFunction.suspendFunction: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
30+
var IrSimpleFunction.suspendFunction: IrSimpleFunction? by irAttribute(copyByDefault = false)
3231

33-
var IrFunction.defaultArgumentsOriginalFunction: IrFunction? by irAttribute(followAttributeOwner = false)
32+
var IrFunction.defaultArgumentsOriginalFunction: IrFunction? by irAttribute(copyByDefault = false)
3433

3534
open class Mapping {
3635
val capturedConstructors: MapBasedMapping<IrConstructor, IrConstructor> = MapBasedMapping()
@@ -90,7 +89,7 @@ open class Mapping {
9089
private lateinit var mapping: AttributeBasedMapping<K, V>
9190

9291
operator fun provideDelegate(thisRef: Any?, desc: KProperty<*>): AttributeBasedMappingDelegate<K, V> {
93-
val attribute = irAttribute<K, V>(followAttributeOwner = false).provideDelegate(thisRef, desc)
92+
val attribute = irAttribute<K, V>(copyByDefault = false).provideDelegate(thisRef, desc)
9493
this.mapping = AttributeBasedMapping(attribute)
9594
return this
9695
}

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,4 @@ class InlineClassLowering(val context: CommonBackendContext) {
366366
)
367367
}
368368

369-
private var IrFunction.staticMethod: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
369+
private var IrFunction.staticMethod: IrSimpleFunction? by irAttribute(copyByDefault = false)

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ val BOUND_VALUE_PARAMETER by IrDeclarationOriginImpl.Synthetic
5454

5555
val BOUND_RECEIVER_PARAMETER by IrDeclarationOriginImpl.Synthetic
5656

57-
private var IrSymbolOwner.scopeWithCounter: ScopeWithCounter? by irAttribute(followAttributeOwner = false)
57+
private var IrSymbolOwner.scopeWithCounter: ScopeWithCounter? by irAttribute(copyByDefault = false)
5858

5959
/*
6060
* Moves local declarations into nearest declaration container.

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/KlibSyntheticAccessorGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class KlibSyntheticAccessorGenerator(
3434
private const val TOP_LEVEL_DECLARATION_SUFFIX_MARKER = "t"
3535

3636
private var IrValueParameter.outerThisSyntheticAccessors: MutableMap<OuterThisAccessorKey, IrSimpleFunction>? by irAttribute(
37-
followAttributeOwner = false
37+
copyByDefault = false
3838
)
3939
}
4040

compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/SyntheticAccessorGenerator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ abstract class SyntheticAccessorGenerator<Context : LoweringContext, ScopeInfo>(
5454

5555
const val PROPERTY_MARKER = "p"
5656

57-
private var IrFunction.syntheticAccessors: MutableMap<AccessorKey, IrFunction>? by irAttribute(followAttributeOwner = false)
58-
private var IrField.getterSyntheticAccessors: MutableMap<AccessorKey, IrSimpleFunction>? by irAttribute(followAttributeOwner = false)
59-
private var IrField.setterSyntheticAccessors: MutableMap<AccessorKey, IrSimpleFunction>? by irAttribute(followAttributeOwner = false)
57+
private var IrFunction.syntheticAccessors: MutableMap<AccessorKey, IrFunction>? by irAttribute(copyByDefault = false)
58+
private var IrField.getterSyntheticAccessors: MutableMap<AccessorKey, IrSimpleFunction>? by irAttribute(copyByDefault = false)
59+
private var IrField.setterSyntheticAccessors: MutableMap<AccessorKey, IrSimpleFunction>? by irAttribute(copyByDefault = false)
6060
}
6161

6262
fun getSyntheticFunctionAccessor(expression: IrFunctionAccessExpression, scopeInfo: ScopeInfo): IrFunction {

compiler/ir/backend.common/test/org/jetbrains/kotlin/backend/common/IrAttributeTests.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import kotlin.test.Test
1616
import kotlin.test.assertEquals
1717
import kotlin.test.assertTrue
1818

19-
private val fooAttr = irAttribute<IrExpression, Int>(followAttributeOwner = true).create(null, "foo")
19+
private val fooAttr = irAttribute<IrExpression, Int>(copyByDefault = true).create(null, "foo")
2020
private var IrExpression.foo: Int? by fooAttr
21-
private val barAttr = irAttribute<IrExpression, Boolean>(followAttributeOwner = true).create(null, "bar")
21+
private val barAttr = irAttribute<IrExpression, Boolean>(copyByDefault = true).create(null, "bar")
2222
private var IrExpression.bar: Boolean? by barAttr
23-
private val bazAttr = irAttribute<IrExpression, String>(followAttributeOwner = true).create(null, "baz")
23+
private val bazAttr = irAttribute<IrExpression, String>(copyByDefault = true).create(null, "baz")
2424
private var IrExpression.baz: String? by bazAttr
2525

2626
class IrAttributeTests {
@@ -157,7 +157,7 @@ class IrAttributeTests {
157157
@Test
158158
fun stressTest() {
159159
val element = createIrElement()
160-
val attributes = List(10) { irAttribute<IrExpression, Int>(followAttributeOwner = true).create(null, "attr$it") }
160+
val attributes = List(10) { irAttribute<IrExpression, Int>(copyByDefault = true).create(null, "attr$it") }
161161
val realAttributeValues = mutableMapOf<IrAttribute<IrExpression, Int>, Int?>()
162162

163163
val rng = Random(1)

compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrAttributes.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.ir.expressions.IrCall
1818
/**
1919
* Whether the class's ES6 constructor requires an additional `box` value parameter.
2020
*/
21-
internal var IrClass.needsBoxParameter: Boolean by irFlag(followAttributeOwner = false)
21+
internal var IrClass.needsBoxParameter: Boolean by irFlag(copyByDefault = false)
2222

2323
/**
2424
* The parameterless constructor that will be used to create instances with `KClass<*>.createInstance`.
@@ -27,37 +27,37 @@ internal var IrClass.needsBoxParameter: Boolean by irFlag(followAttributeOwner =
2727
* a constructor could be replaced by a factory function.
2828
* [findDefaultConstructorForReflection] will respect that.
2929
*/
30-
internal var IrClass.defaultConstructorForReflection: IrConstructor? by irAttribute(followAttributeOwner = false)
30+
internal var IrClass.defaultConstructorForReflection: IrConstructor? by irAttribute(copyByDefault = false)
3131

3232
/**
3333
* The factory function which this constructor is replaced by.
3434
*/
35-
internal var IrConstructor.constructorFactory: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
35+
internal var IrConstructor.constructorFactory: IrSimpleFunction? by irAttribute(copyByDefault = false)
3636

3737
/**
3838
* If [this] is a `main` function, the wrapper that actually calls the `main` function.
3939
*
4040
* @see org.jetbrains.kotlin.ir.backend.js.lower.MainFunctionCallWrapperLowering
4141
*/
42-
internal var IrSimpleFunction.mainFunctionWrapper: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
42+
internal var IrSimpleFunction.mainFunctionWrapper: IrSimpleFunction? by irAttribute(copyByDefault = false)
4343

4444
/**
4545
* If `this` is an object, contains the corresponding `getInstance` function that returns the single instance of the object.
4646
*
4747
* @see org.jetbrains.kotlin.ir.backend.js.lower.ObjectDeclarationLowering
4848
*/
49-
var IrClass.objectGetInstanceFunction: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
49+
var IrClass.objectGetInstanceFunction: IrSimpleFunction? by irAttribute(copyByDefault = false)
5050

5151
/**
5252
* If `this` is an object, contains the field in which the singletone instance of the object is stored.
5353
*
5454
* @see org.jetbrains.kotlin.ir.backend.js.lower.ObjectDeclarationLowering
5555
*/
56-
internal var IrClass.objectInstanceField: IrField? by irAttribute(followAttributeOwner = false)
56+
internal var IrClass.objectInstanceField: IrField? by irAttribute(copyByDefault = false)
5757

5858
/**
5959
* The external constructor, whose delegation call was replaced in ES6 mode.
6060
* The attribute is used inside the [ES6PrimaryConstructorOptimizationLowering] to re-construct the original delegation call
6161
* in constructors that could be translated into simple ES6 class constructors.
6262
*/
63-
internal var IrCall.originalConstructor: IrConstructor? by irAttribute(followAttributeOwner = false)
63+
internal var IrCall.originalConstructor: IrConstructor? by irAttribute(copyByDefault = false)

compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ES6ConstructorBoxParameterOptimizationLowering.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
3131
import org.jetbrains.kotlin.utils.compactIfPossible
3232
import org.jetbrains.kotlin.utils.filterIsInstanceAnd
3333

34-
private var IrSimpleFunction.replacementWithoutBoxParameter: IrSimpleFunction? by irAttribute(followAttributeOwner = false)
34+
private var IrSimpleFunction.replacementWithoutBoxParameter: IrSimpleFunction? by irAttribute(copyByDefault = false)
3535

3636
/**
3737
* Optimization: replaces constructors with the `box` parameter with constructors without the `box` parameter where possible.

compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ES6PrimaryConstructorOptimizationLowering.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.utils.newHashMapWithExpectedSize
3030

3131
const val CREATE_EXTERNAL_THIS_CONSTRUCTOR_PARAMETERS = 2
3232

33-
private var IrClass.possibilityToOptimizeForEsClass: MutableReference<Boolean>? by irAttribute(followAttributeOwner = false)
33+
private var IrClass.possibilityToOptimizeForEsClass: MutableReference<Boolean>? by irAttribute(copyByDefault = false)
3434

3535
/**
3636
* Optimization: replaces synthetically generated static factory method with a plain old ES6 constructor whenever it's possible.

0 commit comments

Comments
 (0)