166c771e1b
If we want to analyse some function's call, we need to know about its contracts, otherwise resolving the following code would be broken. Computing return type of function is a prerequisite to using it in any sensible way, so it's the best place to resolve it to CONTRACTS KT-50733
27 lines
509 B
Kotlin
Vendored
27 lines
509 B
Kotlin
Vendored
// SKIP_JAVAC
|
|
// This directive is needed to skip this test in LazyBodyIsNotTouchedTilContractsPhaseTestGenerated,
|
|
// because it fails to parse module structure of multimodule test
|
|
|
|
// WITH_STDLIB
|
|
|
|
// MODULE: lib
|
|
package lib
|
|
|
|
import kotlin.contracts.*
|
|
|
|
fun requireIsTrue(value: Boolean) contract [
|
|
returns() implies value
|
|
] {
|
|
if (!value) throw IllegalArgumentException()
|
|
}
|
|
|
|
// MODULE: main(lib)
|
|
package main
|
|
|
|
import lib.requireIsTrue
|
|
|
|
fun test(s: Any) {
|
|
requireIsTrue(s is String)
|
|
s.length
|
|
}
|