Add test on safecall of function with returns(null) contract
Currently with non-desired testdata, fix incoming in the next commit.
This commit is contained in:
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
fun Any.nullWhenString(): Any? {
|
||||
contract {
|
||||
returns(null) implies (this@nullWhenString is String)
|
||||
}
|
||||
return if (this is String) null else this
|
||||
}
|
||||
|
||||
fun test(x: Int?) {
|
||||
if (x?.nullWhenString() == null) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ x: kotlin.Int?): kotlin.Unit
|
||||
public fun kotlin.Any.nullWhenString(): kotlin.Any?
|
||||
Returns(NULL) -> <this> is String
|
||||
Reference in New Issue
Block a user