[IR] Extend test coverage for smart cast handling.

This commit is contained in:
Mads Ager
2021-01-07 13:56:02 +01:00
committed by Dmitry Petrov
parent 6fc0de39c2
commit dfc86feecd
28 changed files with 732 additions and 18 deletions
@@ -0,0 +1,8 @@
fun test(x: Any?, y: Double) =
x is Int && x < y
fun box(): String =
if (!test(0, -0.0))
"OK"
else
"Failed"
@@ -0,0 +1,22 @@
interface IC1 {
operator fun component1(): String
}
interface IC2 {
operator fun component2(): String
}
class A : IC1, IC2 {
override fun component1(): String = "O"
override fun component2(): String = "K"
}
fun test(x: Any): String {
if (x is IC1 && x is IC2) {
val (x1, x2) = x
return "$x1$x2"
}
return "FAIL"
}
fun box(): String = test(A())
@@ -0,0 +1,22 @@
// FILE: test.kt
fun test(a: Any) {
a as (String) -> String
J.use(a)
}
fun box(): String {
test({s: String? -> s})
return "OK"
}
// FILE: JFoo.java
public interface JFoo<T> {
T foo(T x);
}
// FILE: J.java
public class J {
public static void use(JFoo<String> jfoo) {
jfoo.foo(null);
}
}