// ISSUES: KT-57911, KT-56744 import kotlin.contracts.ExperimentalContracts import kotlin.contracts.contract abstract class Base { @OptIn(ExperimentalContracts::class) fun checkNotNull(s: String?) { contract { returns() implies (s != null) } s!! } @OptIn(ExperimentalContracts::class) fun checkIsT(s: Any?): Boolean { contract { returns(true) implies (s is T) } return false } @OptIn(ExperimentalContracts::class) fun checkIsOwnerR(s: Any?): Boolean { contract { returns(true) implies (s is R) } return false } @OptIn(ExperimentalContracts::class) inline fun checkIsReifiedR(s: Any?): Boolean { contract { returns(true) implies (s is R) } return false } open fun foo(s: String?) { checkNotNull(s) s.length } } class Derived: Base() { override fun foo(s: String?) { checkNotNull(s) s.length } fun test_1(s: Any) { if (checkIsT(s)) { s.length } } fun test_2(s: Any) { if (checkIsOwnerR(s)) { s.length } } fun test_3(s: Any) { if (checkIsReifiedR(s)) { s.length } } } fun test_1(d: Derived, s: String?) { d.checkNotNull(s) s.length } fun test_2(d: Derived, s: Any?) { if (d.checkIsT(s)) { s.length } } fun test_3(d: Derived, s: Any?) { if (d.checkIsOwnerR(s)) { s.length } } fun test_4(d: Derived, s: Any?) { if (d.checkIsReifiedR(s)) { s.length } }