[JVM IR] Copy metadata in IrFieldBuilder.
This fixes an issue with lateinit properties where the metadata from the original field was not copied to the nullable field in LateinitLowering. Also consolidated related tests.
This commit is contained in:
committed by
Alexander Udalov
parent
f5f25224b0
commit
e226561150
+1
@@ -47,6 +47,7 @@ fun IrFieldBuilder.buildField(): IrField {
|
||||
name, type, visibility, isFinal, isExternal, isStatic,
|
||||
origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
).also {
|
||||
it.metadata = metadata
|
||||
wrappedDescriptor.bind(it)
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -181,7 +181,6 @@ class JvmDeclarationFactory(
|
||||
initializer = oldField.initializer
|
||||
?.replaceThisByStaticReference(this@JvmDeclarationFactory, oldParent, oldParent.thisReceiver!!)
|
||||
?.patchDeclarationParents(this) as IrExpressionBody?
|
||||
(this as IrFieldImpl).metadata = oldField.metadata
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.ir.builders.declarations
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
|
||||
class IrFieldBuilder : IrDeclarationBuilder() {
|
||||
@@ -15,6 +16,7 @@ class IrFieldBuilder : IrDeclarationBuilder() {
|
||||
var isFinal: Boolean = false
|
||||
var isExternal: Boolean = false
|
||||
var isStatic: Boolean = false
|
||||
var metadata: MetadataSource.Property? = null
|
||||
|
||||
fun updateFrom(from: IrField) {
|
||||
super.updateFrom(from)
|
||||
@@ -23,5 +25,6 @@ class IrFieldBuilder : IrDeclarationBuilder() {
|
||||
isFinal = from.isFinal
|
||||
isExternal = from.isExternal
|
||||
isStatic = from.isStatic
|
||||
metadata = from.metadata
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user