Skip to content

Commit d8b40b5

Browse files
mcpiromanSpace Team
authored andcommitted
[IR] Add kdoc to IrElement.copyAttributes
KT-74331 KT-74295
1 parent 7fdece7 commit d8b40b5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarations.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ import org.jetbrains.kotlin.name.Name
1818
import org.jetbrains.kotlin.name.NameUtils.getPackagePartClassNamePrefix
1919
import java.io.File
2020

21+
/**
22+
* This does two different things:
23+
* 1. Copies [IrAttribute]s of element [other] into [this]. Attributes already present on [this] are not removed, attributes present
24+
* overridden on both [this] and [other] will be overridden in [this]. The semantics is therefore the same as [MutableMap.putAll].
25+
* 2. Assigns [IrElement.attributeOwnerId] to that of [other].
26+
*
27+
* Now, those two operations are not clearly connected to each other, although they have been historically.
28+
* In particular, [IrElement.attributeOwnerId] has lost much of its meaning since, and is _not_ connected to [IrAttribute]s.
29+
* But still, _most likely_ you want to do both at the same time, which is what we do here. It should be investigated closer in KT-74295.
30+
*
31+
* @param includeAll if `true`, copy all the attributes present in [other],
32+
* if `false`, only those with [IrAttribute.copyByDefault] == `true`.
33+
*/
2134
fun IrElement.copyAttributes(other: IrElement, includeAll: Boolean = false) {
2235
(this as IrElementBase).copyAttributesFrom(other as IrElementBase, includeAll)
2336
attributeOwnerId = other.attributeOwnerId

0 commit comments

Comments
 (0)