Support lateinit local vars in JVM BE

This commit is contained in:
Dmitry Petrov
2017-05-31 16:03:04 +03:00
parent 53961e8df0
commit c5b9d500bc
13 changed files with 363 additions and 17 deletions
@@ -0,0 +1,9 @@
fun runNoInline(f: () -> Unit) = f()
fun box(): String {
lateinit var ok: String
runNoInline {
ok = "OK"
}
return ok
}
@@ -0,0 +1,7 @@
fun box(): String {
lateinit var ok: String
run {
ok = "OK"
}
return ok
}
@@ -0,0 +1,21 @@
// WITH_REFLECT
import kotlin.UninitializedPropertyAccessException
fun runNoInline(f: () -> Unit) = f()
fun box(): String {
lateinit var str: String
var i: Int = 0
try {
runNoInline {
i = str.length
}
return "Should throw an exception"
}
catch (e: UninitializedPropertyAccessException) {
return "OK"
}
catch (e: Throwable) {
return "Unexpected exception: ${e::class.qualifiedName}"
}
}
@@ -0,0 +1,21 @@
// WITH_REFLECT
import kotlin.UninitializedPropertyAccessException
fun runNoInline(f: () -> Unit) = f()
fun box(): String {
lateinit var str: String
var str2: String = ""
try {
runNoInline {
str2 = str
}
return "Should throw an exception"
}
catch (e: UninitializedPropertyAccessException) {
return "OK"
}
catch (e: Throwable) {
return "Unexpected exception: ${e::class.qualifiedName}"
}
}
@@ -0,0 +1,17 @@
// WITH_REFLECT
import kotlin.UninitializedPropertyAccessException
fun box(): String {
lateinit var str: String
var i: Int = 0
try {
i = str.length
return "Should throw an exception"
}
catch (e: UninitializedPropertyAccessException) {
return "OK"
}
catch (e: Throwable) {
return "Unexpected exception: ${e::class.qualifiedName}"
}
}
@@ -0,0 +1,17 @@
// WITH_REFLECT
import kotlin.UninitializedPropertyAccessException
fun box(): String {
lateinit var str: String
var str2: String = ""
try {
str2 = str
return "Should throw an exception"
}
catch (e: UninitializedPropertyAccessException) {
return "OK"
}
catch (e: Throwable) {
return "Unexpected exception: ${e::class.qualifiedName}"
}
}