Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.kt
T
Dmitry Savvinov 57bafcf9e9 Do not lose information about contracts if call uses default value
It is safe to treat DefaultValueArgument as UNKNOWN_COMPUTATION, because
default arguments can't break smartcasts.

Possibly, they can add new ones, but it can be supported later.

^KT-25278 Fixed
2018-08-10 13:19:32 +03:00

16 lines
432 B
Kotlin
Vendored

// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
import kotlin.internal.contracts.*
fun myAssert(condition: Boolean, message: String = "") {
contract {
returns() implies (condition)
}
if (!condition) throw kotlin.IllegalArgumentException(message)
}
fun test(x: Any?) {
myAssert(x is String)
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}