Local declarations and initializers fixes (#222)
* captured values are stored in corresponding fields before call to super constructor * preserving the order of initializers * tests * refactoring * - test fix - workaround of IR bug * refactoring * review fix
This commit is contained in:
@@ -404,6 +404,21 @@ task localClass_innerTakesCapturedFromOuter(type: RunKonanTest) {
|
||||
source = "codegen/localClass/innerTakesCapturedFromOuter.kt"
|
||||
}
|
||||
|
||||
task localClass_virtualCallFromConstructor(type: RunKonanTest) {
|
||||
goldValue = "OK\n"
|
||||
source = "codegen/localClass/virtualCallFromConstructor.kt"
|
||||
}
|
||||
|
||||
task initializers_correctOrder1(type: RunKonanTest) {
|
||||
goldValue = "42\n"
|
||||
source = "codegen/initializers/correctOrder1.kt"
|
||||
}
|
||||
|
||||
task initializers_correctOrder2(type: RunKonanTest) {
|
||||
goldValue = "42\n"
|
||||
source = "codegen/initializers/correctOrder2.kt"
|
||||
}
|
||||
|
||||
task array0(type: RunKonanTest) {
|
||||
goldValue = "5\n6\n7\n8\n9\n10\n11\n12\n13\n"
|
||||
source = "runtime/collections/array0.kt"
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class Test {
|
||||
val x: Int
|
||||
|
||||
init {
|
||||
x = 42
|
||||
}
|
||||
|
||||
val y = x
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(Test().y)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class Test {
|
||||
val x: Int
|
||||
|
||||
val y = 42
|
||||
|
||||
init {
|
||||
x = y
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(Test().x)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
abstract class WaitFor {
|
||||
init {
|
||||
condition()
|
||||
}
|
||||
|
||||
abstract fun condition(): Boolean;
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val local = ""
|
||||
var result = "fail"
|
||||
val s = object : WaitFor() {
|
||||
|
||||
override fun condition(): Boolean {
|
||||
result = "OK"
|
||||
return result.length == 2
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(box())
|
||||
}
|
||||
@@ -6,10 +6,6 @@ fun foo() : String {
|
||||
return u()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return foo()
|
||||
}
|
||||
Reference in New Issue
Block a user