Check type of elvis with expected type info

#KT-6713
This commit is contained in:
Denis Zharkov
2015-07-17 13:00:48 +03:00
parent 53edb83a56
commit 3ec00114c0
4 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
class RightElvisOperand {
static String foo() {
return null;
}
}

View File

@@ -0,0 +1,21 @@
fun baz(): String? = null
fun bar(): String = baz() ?: RightElvisOperand.foo()
fun foo(x: String) {}
fun box(): String {
try {
foo(baz() ?: RightElvisOperand.foo())
return "Fail: should have been an exception in `foo(baz() ?: RightElvisOperand.foo())`"
}
catch(e: IllegalStateException) {}
try {
bar()
return "Fail: should have been an exception in `bar()`"
}
catch(e: IllegalStateException) {
return "OK"
}
}