Using const val from module doesn't mean we had to run initializers anymore.
This commit is contained in:
+8
-4
@@ -1425,11 +1425,15 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
fieldPtrOfClass(thisPtr, value.symbol.owner), value.descriptor.isVar())
|
||||
} else {
|
||||
assert(value.receiver == null)
|
||||
if (context.config.threadsAreAllowed && value.symbol.owner.isMainOnlyNonPrimitive) {
|
||||
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
|
||||
return if (value.symbol.owner.correspondingProperty?.isConst == true) {
|
||||
evaluateConst(value.symbol.owner.initializer?.expression as IrConst<*>)
|
||||
} else {
|
||||
if (context.config.threadsAreAllowed && value.symbol.owner.isMainOnlyNonPrimitive) {
|
||||
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
|
||||
}
|
||||
val ptr = context.llvmDeclarations.forStaticField(value.symbol.owner).storage
|
||||
functionGenerationContext.loadSlot(ptr, value.descriptor.isVar())
|
||||
}
|
||||
val ptr = context.llvmDeclarations.forStaticField(value.symbol.owner).storage
|
||||
return functionGenerationContext.loadSlot(ptr, value.descriptor.isVar())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1080,7 +1080,7 @@ internal class IrModuleSerializer(
|
||||
// Make sure that all top level properties are initialized on library's load.
|
||||
file.declarations
|
||||
.filterIsInstance<IrProperty>()
|
||||
.filter { it.backingField?.initializer != null }
|
||||
.filter { it.backingField?.initializer != null && !it.isConst }
|
||||
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
|
||||
|
||||
file.acceptVoid(object: IrElementVisitorVoid {
|
||||
|
||||
@@ -6,3 +6,4 @@ kotlin_version=1.3.21
|
||||
|
||||
# Use custom Kotlin/Native home:
|
||||
org.jetbrains.kotlin.native.home=../../dist
|
||||
org.gradle.workers.max=4
|
||||
|
||||
Reference in New Issue
Block a user