[JS IR] Assert createdOn equals 0 for properties initialization fun for file
This commit is contained in:
+12
-2
@@ -50,11 +50,13 @@ class PropertyLazyInitLowering(
|
||||
if (container !is IrField && container !is IrSimpleFunction && container !is IrProperty)
|
||||
return
|
||||
|
||||
if (container.origin !in compatibleOrigins) return
|
||||
if (!container.isCompatibleDeclaration()) return
|
||||
|
||||
val file = container.parent as? IrFile
|
||||
?: return
|
||||
|
||||
container.assertCompatibleDeclaration()
|
||||
|
||||
val initFun = (when {
|
||||
file in fileToInitializationFuns -> fileToInitializationFuns[file]
|
||||
fileToInitializerPureness[file] == true -> null
|
||||
@@ -242,7 +244,10 @@ class RemoveInitializersForLazyProperties(
|
||||
declaration.correspondingProperty
|
||||
?.takeIf { it.isForLazyInit() }
|
||||
?.backingField
|
||||
?.let { it.initializer = null }
|
||||
?.let {
|
||||
it.assertCompatibleDeclaration()
|
||||
it.initializer = null
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -298,9 +303,14 @@ private fun IrDeclaration.propertyWithPersistentSafe(transform: IrDeclaration.()
|
||||
private fun IrDeclaration.isCompatibleDeclaration() =
|
||||
origin in compatibleOrigins
|
||||
|
||||
private fun IrDeclaration.assertCompatibleDeclaration() {
|
||||
assert((this as? PersistentIrElementBase<*>)?.createdOn?.let { it == 0 } != false)
|
||||
}
|
||||
|
||||
private val compatibleOrigins = listOf(
|
||||
IrDeclarationOrigin.DEFINED,
|
||||
IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR,
|
||||
IrDeclarationOrigin.PROPERTY_DELEGATE,
|
||||
IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR,
|
||||
IrDeclarationOrigin.PROPERTY_BACKING_FIELD,
|
||||
)
|
||||
+5
@@ -1,12 +1,17 @@
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// PROPERTY_LAZY_INITIALIZATION
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
// FILE: A.kt
|
||||
val a1 = "a".let {
|
||||
it + "a"
|
||||
}
|
||||
|
||||
val b1 by lazy {
|
||||
"b1"
|
||||
}
|
||||
|
||||
object A {
|
||||
private val foo = "foo"
|
||||
val foo2 = foo
|
||||
|
||||
Reference in New Issue
Block a user