b29a6e48fb
- Introduce new language feature 'ReadDeserializedContracts', which allows to deserialize contracts from metadata. - Introduce new language feature 'AllowContractsForCustomFunctions', which allows reading contracts from sources. - Use new features instead of combination 'CallsInPlaceEffect || ReturnsEffect' - Rename 'CallsInPlaceEffect' -> 'UseCallsInPlaceEffect', 'ReturnsEffect' -> 'UseReturnsEffect'. As names suggest, they control if it is allowed to use corresponding effect in analysis. We have to introduce separate 'ReadDeserializedContracts' to enable contracts only in some modules of the project, because libraries are read with project-wide settings (see KT-20692).
27 lines
734 B
Kotlin
Vendored
27 lines
734 B
Kotlin
Vendored
// !LANGUAGE: +ReadDeserializedContracts +UseReturnsEffect
|
|
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
|
|
|
fun testRequireSmartcast(x: Any?) {
|
|
require(x is String)
|
|
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
|
}
|
|
|
|
fun testRequireUnreachableCode() {
|
|
require(false)
|
|
println("Can't get here!")
|
|
}
|
|
|
|
fun testRequireWithMessage(x: Any?) {
|
|
require(x is String) { "x is not String!" }
|
|
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
|
}
|
|
|
|
fun testRequireWithFailingMessage(x: Any?) {
|
|
require(x is String) { throw kotlin.IllegalStateException("What a strange idea") }
|
|
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
|
}
|
|
|
|
fun tesRequireNotNullWithMessage(x: Int?) {
|
|
requireNotNull(x) { "x is null!"}
|
|
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
|
|
} |