Tests for issues fixed in JVM_IR

This commit is contained in:
Dmitry Petrov
2020-12-21 15:41:21 +03:00
parent 5e5b236ef8
commit 443cd0fc2c
19 changed files with 364 additions and 1 deletions
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM
// IGNORE_LIGHT_ANALYSIS
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: PROPERTY_REFERENCES
fun box(): String {
val ints = intArrayOf(1, 2, 3)
val test1 = IntArray::size.get(ints)
if (test1 != 3) throw Exception("IntArray::size.get(ints) != 3: $test1")
val test2 = with(ints, IntArray::size)
if (test2 != 3) throw Exception("with(ints, IntArray::size) != 3: $test2")
return "OK"
}
@@ -0,0 +1,35 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: kt18911.kt
fun testNullString() {
try {
val t1 = J.nullString()::capitalize
throw Exception("'J.nullString()::capitalize' should throw")
} catch (e: NullPointerException) {}
}
fun testNotNullString() {
try {
val t1 = J.notNullString()::capitalize
throw Exception("'J.notNullString()::capitalize' should throw")
} catch (e: NullPointerException) {}
}
fun box(): String {
testNullString()
testNotNullString()
return "OK"
}
// FILE: J.java
import org.jetbrains.annotations.NotNull;
public class J {
public static String nullString() {
return null;
}
public static @NotNull String notNullString() {
return null;
}
}
@@ -0,0 +1,11 @@
// IGNORE_BACKEND: JVM
open class Base(val fn: () -> String)
class Test(x: String) :
Base({
class Local(val t: String = x)
Local().t
})
fun box() =
Test("OK").fn()
+16
View File
@@ -0,0 +1,16 @@
// IGNORE_BACKEND: JVM
class X(val x: String) {
open inner class Y {
fun foo() = x
}
fun foo(s: String): String {
with(X(s+x)) {
val obj = object : Y() {}
return obj.foo()
}
}
}
fun box() =
X("K").foo("O")
+22
View File
@@ -0,0 +1,22 @@
// IGNORE_BACKEND: JVM
fun <T, R> with2(receiver: T, block: T.() -> R): R {
return receiver.block()
}
class X(val x: String) {
open inner class Y {
fun foo() = x
}
fun foo(s: String): String {
var t = ""
with2(X(s+x)) {
val obj = object : Y() {}
t = obj.foo()
}
return t
}
}
fun box() =
X("K").foo("O")