Fixed issue with TL initializers + tests

Put all top level properties into the list of explicitly exported symbols
This commit is contained in:
Igor Chevdar
2019-02-19 10:54:47 +05:00
parent ae29fc5e1a
commit 5a41e9b257
6 changed files with 26 additions and 0 deletions
@@ -1077,6 +1077,12 @@ internal class IrModuleSerializer(
proto.addDeclarationId(protoUniqId(uniqId))
}
// Make sure that all top level properties are initialized on library's load.
file.declarations
.filterIsInstance<IrProperty>()
.filter { it.backingField?.initializer != null }
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
file.acceptVoid(object: IrElementVisitorVoid {
override fun visitElement(element: IrElement) {
element.acceptChildrenVoid(this)
+12
View File
@@ -1084,6 +1084,18 @@ task initializers_correctOrder2(type: RunKonanTest) {
source = "codegen/initializers/correctOrder2.kt"
}
task initializers_linkTest1(type: LinkKonanTest) {
goldValue = "1200\n"
source = "codegen/initializers/linkTest1_main.kt"
lib = "codegen/initializers/linkTest1_lib.kt"
}
task initializers_linkTest2(type: LinkKonanTest) {
goldValue = "2\n"
source = "codegen/initializers/linkTest2_main.kt"
lib = "codegen/initializers/linkTest2_lib.kt"
}
task arithmetic_basic(type: RunKonanTest) {
source = "codegen/arithmetic/basic.kt"
}
@@ -0,0 +1,3 @@
val a = 10
val b = a * 6
val c = a * b * 2
@@ -0,0 +1 @@
fun main() = println(c)
@@ -0,0 +1,3 @@
val a = mutableListOf<Int>()
val b = 1.also { a += 2 }
val c = a.single()
@@ -0,0 +1 @@
fun main() = println(c)