diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index bd8d8d19a45..4a2777441a3 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -597,11 +597,12 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid context.log("visitField : ${ir2string(expression)}") val descriptor = expression.descriptor if (descriptor.containingDeclaration is PackageFragmentDescriptor) { - val globalProperty = LLVMAddGlobal(context.llvmModule, codegen.getLLVMType(descriptor.type), descriptor.symbolName) + val type = codegen.getLLVMType(descriptor.type) + val globalProperty = LLVMAddGlobal(context.llvmModule, type, descriptor.symbolName) if (expression.initializer!!.expression is IrConst<*>) { LLVMSetInitializer(globalProperty, evaluateExpression(expression.initializer!!.expression)) } else { - LLVMSetInitializer(globalProperty, codegen.kNullObjHeaderPtr) + LLVMSetInitializer(globalProperty, LLVMConstNull(type)) context.llvm.fileInitializers.add(expression) } return diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 33cb0df9721..0a436dd72f3 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -829,8 +829,7 @@ task initializers3(type: RunKonanTest) { } task initializers4(type: RunKonanTest) { - disabled = true - goldValue = "fixme\n" + goldValue = "1073741824\ntrue\n" source = "runtime/basic/initializers4.kt" } diff --git a/runtime/src/main/kotlin/kotlin/Array.kt b/runtime/src/main/kotlin/kotlin/Array.kt index 6bb2387e3fe..7b02c11f628 100644 --- a/runtime/src/main/kotlin/kotlin/Array.kt +++ b/runtime/src/main/kotlin/kotlin/Array.kt @@ -46,6 +46,8 @@ private class IteratorImpl(val collection: Array) : Iterator { } } +fun arrayOf(vararg elements: T) : Array = elements + public fun > Array.toCollection(destination: C): C { for (item in this) { destination.add(item)