mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
Check type of elvis with expected type info
#KT-6713
This commit is contained in:
5
compiler/testData/codegen/boxAgainstJava/notNullAssertions/RightElvisOperand.java
vendored
Normal file
5
compiler/testData/codegen/boxAgainstJava/notNullAssertions/RightElvisOperand.java
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class RightElvisOperand {
|
||||
static String foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
21
compiler/testData/codegen/boxAgainstJava/notNullAssertions/RightElvisOperand.kt
vendored
Normal file
21
compiler/testData/codegen/boxAgainstJava/notNullAssertions/RightElvisOperand.kt
vendored
Normal 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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user