Add 'mute' concept: move tests with unexpected behaviour to the corresponding folder

This commit is contained in:
victor.petukhov
2018-09-25 12:16:29 +03:00
parent 84dc28374c
commit ecb3f10e47
48 changed files with 1505 additions and 913 deletions
@@ -50,5 +50,9 @@ fun case_6(value_1: _EnumClass): String {
}
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty enum class.
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty enum class.
DISCUSSION
ISSUES: KT-26044
*/
fun case_7(value_1: _EnumClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { }
@@ -64,15 +64,6 @@ fun case_8(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(val
_SealedMixedChildObject1 -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable sealed class (without subtypes).
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-26044
*/
fun case_9(value: _SealedClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable Any.
DISCUSSION: maybe make exhaustive without else?
@@ -82,28 +73,9 @@ fun case_10(value_1: Any?): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types.
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996
*/
fun case_11(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3?, <!USELESS_IS_CHECK!>is _SealedChild3?<!> -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types.
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996
*/
fun case_12(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3 -> ""
<!USELESS_IS_CHECK!>is _SealedChild3?<!> -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty sealed class (without subtypes).
DISCUSSION
ISSUES: KT-26044
*/
fun case_13(value: _SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {}
fun case_11(value: _SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {}
@@ -44,19 +44,3 @@ fun case_5(value_1: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(valu
fun case_6(value_1: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable enum class.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26044
*/
fun case_7(value: _EnumClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) {
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty enum class.
DISCUSSION
ISSUES: KT-26044
*/
fun case_13(value: _EnumClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {}
@@ -64,3 +64,22 @@ fun case_6(value_1: _SealedClassMixed): String = when (value_1) {
fun case_7(value_1: _SealedClassEmpty): String = when (value_1) {
else -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types.
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996
*/
fun case_8(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3?, <!USELESS_IS_CHECK!>is _SealedChild3?<!> -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types.
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996
*/
fun case_9(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3 -> ""
<!USELESS_IS_CHECK!>is _SealedChild3?<!> -> ""
}
@@ -24,3 +24,12 @@ fun case_2(value_1: _EnumClassSingle?): String = when (value_1) {
_EnumClassSingle.EVERYTHING -> ""
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable enum class.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26044
*/
fun case_3(value_1: _EnumClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> ""
}
@@ -64,3 +64,12 @@ fun case_6(value_1: _SealedClassMixed?): String = when (value_1) {
is _SealedMixedChildObject3 -> ""
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable sealed class (without subtypes).
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-26044
*/
fun case_7(value: _SealedClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
null -> ""
}
@@ -51,11 +51,7 @@ fun case_2(value_1: Int): String {
return ""
}
/*
CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' without bound value.
UNEXPECTED BEHAVIOUR
ISSUES: KT-25268
*/
// CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' without bound value.
fun case_3(value_1: Int): String {
val whenValue = when {
value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
@@ -72,23 +68,17 @@ fun case_3(value_1: Int): String {
whenValue checkType { <!TYPE_MISMATCH!>_<!><Float>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Short>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Number>() } // unexpected behaviour!
checkSubtype<Int>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Long>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Double>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Float>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Short>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Byte>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Number>(<!TYPE_MISMATCH!>whenValue<!>) // unexpected behaviour!
return ""
}
/*
CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' with bound value.
UNEXPECTED BEHAVIOUR
ISSUES: KT-25268
*/
// CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' with bound value.
fun case_4(value_1: Int): String {
val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
@@ -105,14 +95,12 @@ fun case_4(value_1: Int): String {
whenValue checkType { <!TYPE_MISMATCH!>_<!><Float>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Short>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Number>() } // unexpected behaviour!
checkSubtype<Int>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Long>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Double>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Float>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Short>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Byte>(<!TYPE_MISMATCH!>whenValue<!>)
checkSubtype<Number>(<!TYPE_MISMATCH!>whenValue<!>) // unexpected behaviour!
return ""
}
@@ -57,6 +57,8 @@ fun case_3(value_1: Int): String {
}
whenValue checkType { _<Any>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Number>() } // unexpected behaviour!
checkSubtype<Number>(<!TYPE_MISMATCH!>whenValue<!>) // unexpected behaviour!
return ""
}
@@ -77,6 +79,8 @@ fun case_4(value_1: Int): String {
}
whenValue checkType { _<Any>() }
whenValue checkType { <!TYPE_MISMATCH!>_<!><Number>() } // unexpected behaviour!
checkSubtype<Number>(<!TYPE_MISMATCH!>whenValue<!>) // unexpected behaviour!
return ""
}
@@ -0,0 +1,58 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !WITH_CONTRACT_FUNCTIONS
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts
CATEGORIES: analysis, controlFlow, initialization
NUMBER: 6
DESCRIPTION: Check the lack of CallsInPlace effect on the lambda in the parentheses.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26229
*/
// FILE: contracts.kt
package contracts
import kotlin.contracts.*
inline fun case_3(block1: () -> Unit, block2: () -> Unit, block3: () -> Unit) {
contract {
callsInPlace(block1, InvocationKind.EXACTLY_ONCE)
callsInPlace(block2, InvocationKind.AT_LEAST_ONCE)
callsInPlace(block3, InvocationKind.EXACTLY_ONCE)
}
block1()
block2()
block2()
block3()
}
// FILE: usages.kt
import contracts.*
fun case_1() {
val value_1: Int
funWithExactlyOnceCallsInPlace({ <!CAPTURED_VAL_INITIALIZATION!>value_1<!> = 11 })
<!UNINITIALIZED_VARIABLE!>value_1<!>.inc()
}
fun case_2() {
var value_1: Int
funWithAtLeastOnceCallsInPlace({ value_1 = 11 })
<!UNINITIALIZED_VARIABLE!>value_1<!>.inc()
}
fun case_3() {
val value_1: Int
var value_2: Int
val value_3: Int
contracts.case_3({ <!CAPTURED_VAL_INITIALIZATION!>value_1<!> = 1 }, { value_2 = 2 }, { <!CAPTURED_VAL_INITIALIZATION!>value_3<!> = 3 })
<!UNINITIALIZED_VARIABLE!>value_1<!>.inc()
<!UNINITIALIZED_VARIABLE!>value_2<!>.inc()
<!UNINITIALIZED_VARIABLE!>value_3<!>.inc()
}
@@ -0,0 +1,120 @@
package
public fun case_1(): kotlin.Unit
public fun case_2(): kotlin.Unit
public fun case_3(): kotlin.Unit
public inline fun </*0*/ T> funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> T): T
CallsInPlace(block, AT_LEAST_ONCE)
public inline fun funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, AT_LEAST_ONCE)
public inline fun funWithAtMostOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, AT_MOST_ONCE)
public inline fun </*0*/ T> funWithExactlyOnceCallsInPlace(/*0*/ block: () -> T): T
CallsInPlace(block, EXACTLY_ONCE)
public inline fun funWithExactlyOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
public fun funWithReturns(/*0*/ cond: kotlin.Boolean): kotlin.Unit
Returns(WILDCARD) -> cond
public fun funWithReturnsAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Unit
Returns(WILDCARD) -> !cond
public fun funWithReturnsAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 !is String
public fun funWithReturnsAndNotNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 != null
public fun funWithReturnsAndNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 == null
public fun funWithReturnsAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 is String
public fun funWithReturnsFalse(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(FALSE) -> cond
public fun funWithReturnsFalseAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(FALSE) -> !cond
public fun funWithReturnsFalseAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is String
public fun funWithReturnsFalseAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean
Returns(FALSE) -> value_1 != null
public fun funWithReturnsFalseAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean
Returns(FALSE) -> value_1 == null
public fun funWithReturnsFalseAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 is String
public fun funWithReturnsNotNull(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NOT_NULL) -> cond
public fun funWithReturnsNotNullAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NOT_NULL) -> !cond
public fun funWithReturnsNotNullAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is String
public fun funWithReturnsNotNullAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 != null
public fun funWithReturnsNotNullAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 == null
public fun funWithReturnsNotNullAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 is String
public fun funWithReturnsNull(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NULL) -> cond
public fun funWithReturnsNullAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NULL) -> !cond
public fun funWithReturnsNullAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is String
public fun funWithReturnsNullAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NULL) -> value_1 != null
public fun funWithReturnsNullAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NULL) -> value_1 == null
public fun funWithReturnsNullAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 is String
public fun funWithReturnsTrue(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(TRUE) -> cond
public fun funWithReturnsTrueAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(TRUE) -> !cond
public fun funWithReturnsTrueAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is String
public fun funWithReturnsTrueAndNotNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 != null
public fun funWithReturnsTrueAndNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 == null
public fun funWithReturnsTrueAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 is String
public inline fun funWithUnknownCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, UNKNOWN)
package contracts {
public inline fun case_3(/*0*/ block1: () -> kotlin.Unit, /*1*/ block2: () -> kotlin.Unit, /*2*/ block3: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block1, EXACTLY_ONCE)
CallsInPlace(block2, AT_LEAST_ONCE)
CallsInPlace(block3, EXACTLY_ONCE)
}
@@ -1,7 +1,7 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !WITH_CONTRACT_FUNCTIONS
// SKIP_TXT
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
@@ -9,27 +9,488 @@
SECTION: contracts
CATEGORIES: analysis, smartcasts
NUMBER: 10
DESCRIPTION: Check the lack of smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'unknown' or 'at most once' CallsInPlace effects.
DESCRIPTION: Check smartcasts using double negation (returnsFalse/invert type checking/not operator).
ISSUES: KT-26176
*/
fun case_1(arg: Int?) {
funWithAtMostOnceCallsInPlace { arg!! }
arg<!UNSAFE_CALL!>.<!>inc()
// FILE: contracts.kt
package contracts
import kotlin.contracts.*
fun case_1(x: Any?): Boolean {
contract { returns(true) implies (x !is Number) }
return x !is Number
}
fun case_2(arg: Int?) {
funWithUnknownCallsInPlace { arg!! }
arg<!UNSAFE_CALL!>.<!>inc()
fun case_2(x: Any?): Boolean {
contract { returns(true) implies (x !is Number?) }
return x !is Number?
}
fun case_3() {
val value_1: Boolean?
funWithAtMostOnceCallsInPlace { value_1 = false }
<!UNINITIALIZED_VARIABLE!>value_1<!><!UNSAFE_CALL!>.<!>not()
fun case_16_1(value_1: Any?, value_2: Any?): Boolean {
contract { returns(true) implies (value_1 !is String || value_2 !is Number) }
return value_1 !is String || value_2 !is Number
}
fun case_16_2(value_1: Any?, value_2: Any?): Boolean {
contract { returns(false) implies (value_1 !is String || value_2 !is Number) }
return !(value_1 !is String || value_2 !is Number)
}
fun case_16_3(value_1: Any?, value_2: Any?): Boolean? {
contract { returnsNotNull() implies (value_1 !is String || value_2 !is Number) }
return if (value_1 !is String || value_2 !is Number) true else null
}
fun case_16_4(value_1: Any?, value_2: Any?): Boolean? {
contract { returns(null) implies (value_1 !is String || value_2 !is Number) }
return if (value_1 !is String || value_2 !is Number) null else true
}
fun case_4() {
val value_1: Boolean?
funWithUnknownCallsInPlace { <!VAL_REASSIGNMENT!>value_1<!> = true }
<!UNINITIALIZED_VARIABLE!>value_1<!><!UNSAFE_CALL!>.<!>not()
fun case_17_1(value_1: Any?, value_2: Any?): Boolean {
contract { returns(true) implies (value_1 !is String || value_2 != null) }
return value_1 !is String || value_2 != null
}
fun case_17_2(value_1: Any?, value_2: Any?): Boolean {
contract { returns(false) implies (value_1 !is String || value_2 != null) }
return !(value_1 !is String || value_2 != null)
}
fun case_17_3(value_1: Any?, value_2: Any?): Boolean? {
contract { returnsNotNull() implies (value_1 !is String || value_2 != null) }
return if (value_1 !is String || value_2 != null) true else null
}
fun case_17_4(value_1: Any?, value_2: Any?): Boolean? {
contract { returns(null) implies (value_1 !is String || value_2 != null) }
return if (value_1 !is String || value_2 != null) null else true
}
fun case_18_1(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean {
contract { returns(true) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
}
fun case_18_2(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean {
contract { returns(false) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return !(value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null)
}
fun case_18_3(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? {
contract { returnsNotNull() implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return if (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) true else null
}
fun case_18_4(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? {
contract { returns(null) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return if (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) null else true
}
fun <T> T.case_19_1(): Boolean {
contract { returns(true) implies (this@case_19_1 !is String) }
return this@case_19_1 !is String
}
fun <T> T.case_19_2(): Boolean {
contract { returns(false) implies (this@case_19_2 is String) }
return !(this@case_19_2 is String)
}
fun <T> T.case_19_3(): Boolean? {
contract { returnsNotNull() implies (this@case_19_3 is String) }
return if (this@case_19_3 is String) true else null
}
fun <T> T.case_19_4(): Boolean? {
contract { returns(null) implies (this@case_19_4 is String) }
return if (this@case_19_4 is String) null else true
}
fun <T : Number> T.case_20_1(): Boolean {
contract { returns(true) implies (this@case_20_1 !is Int) }
return this@case_20_1 !is Int
}
fun <T : Number> T.case_20_2(): Boolean {
contract { returns(false) implies (this@case_20_2 is Int) }
return !(this@case_20_2 is Int)
}
fun <T : Number> T.case_20_3(): Boolean? {
contract { returnsNotNull() implies (this@case_20_3 is Int) }
return if (this@case_20_3 is Int) true else null
}
fun <T : Number> T.case_20_4(): Boolean? {
contract { returns(null) implies (this@case_20_4 is Int) }
return if (this@case_20_4 is Int) null else true
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_1(): Boolean {
contract { returns(true) implies (this@case_21_1 != null) }
return this@case_21_1 != null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_2(): Boolean {
contract { returns(true) implies (this@case_21_2 == null) }
return this@case_21_2 == null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_3(): Boolean {
contract { returns(false) implies (this@case_21_3 != null) }
return !(this@case_21_3 != null)
}
fun <T : String?> T.case_22_1(): Boolean {
contract { returns(true) implies (this@case_22_1 != null) }
return this@case_22_1 != null
}
fun <T : String?> T.case_22_2(): Boolean {
contract { returns(true) implies (this@case_22_2 == null) }
return this@case_22_2 == null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_22_5(): Boolean? {
contract { returnsNotNull() implies (this@case_22_5 != null) }
return if (this@case_22_5 != null) true else null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_22_7(): Boolean? {
contract { returns(null) implies (this@case_22_7 != null) }
return if (this@case_22_7 != null) null else true
}
fun <T> T?.case_23_1(): Boolean {
contract { returns(false) implies (this@case_23_1 == null || this@case_23_1 !is String) }
return !(this@case_23_1 == null || this@case_23_1 !is String)
}
fun <T> T?.case_23_2(): Boolean? {
contract { returnsNotNull() implies (this@case_23_2 == null || this@case_23_2 !is String) }
return if (this@case_23_2 == null || this@case_23_2 !is String) true else null
}
fun <T> T?.case_23_3(): Boolean? {
contract { returns(null) implies (this@case_23_3 == null || this@case_23_3 !is String) }
return if (this@case_23_3 == null || this@case_23_3 !is String) null else true
}
fun <T : Number?> T.case_24_1(): Boolean {
contract { returns(false) implies (this@case_24_1 !is Int || <!SENSELESS_COMPARISON!>this@case_24_1 == null<!>) }
return !(this@case_24_1 !is Int || <!SENSELESS_COMPARISON!>this@case_24_1 == null<!>)
}
fun <T : Number?> T.case_24_2(): Boolean? {
contract { returnsNotNull() implies (this@case_24_2 !is Int || <!SENSELESS_COMPARISON!>this@case_24_2 == null<!>) }
return if (this@case_24_2 !is Int || <!SENSELESS_COMPARISON!>this@case_24_2 == null<!>) true else null
}
fun <T : Number?> T.case_24_3(): Boolean? {
contract { returns(null) implies (this@case_24_3 !is Int || <!SENSELESS_COMPARISON!>this@case_24_3 == null<!>) }
return if (this@case_24_3 !is Int || <!SENSELESS_COMPARISON!>this@case_24_3 == null<!>) null else true
}
inline fun <reified T : Any?> T?.case_25_1(): Boolean {
contract { returns(false) implies (this@case_25_1 !is Number || this@case_25_1 !is Int || <!SENSELESS_COMPARISON!>this@case_25_1 == null<!>) }
return !(this@case_25_1 !is Number || this@case_25_1 !is Int || <!SENSELESS_COMPARISON!>this@case_25_1 == null<!>)
}
inline fun <reified T : Any?> T?.case_25_2(): Boolean? {
contract { returnsNotNull() implies (this@case_25_2 !is Number || this@case_25_2 !is Int || <!SENSELESS_COMPARISON!>this@case_25_2 == null<!>) }
return if (this@case_25_2 !is Number || this@case_25_2 !is Int || <!SENSELESS_COMPARISON!>this@case_25_2 == null<!>) true else null
}
inline fun <reified T : Any?> T?.case_25_3(): Boolean? {
contract { returns(null) implies (this@case_25_3 !is Number || this@case_25_3 !is Int || <!SENSELESS_COMPARISON!>this@case_25_3 == null<!>) }
return if (this@case_25_3 !is Number || this@case_25_3 !is Int || <!SENSELESS_COMPARISON!>this@case_25_3 == null<!>) null else true
}
fun <T> T?.case_26_1(value_1: Int?): Boolean {
contract { returns(false) implies (this@case_26_1 == null || this@case_26_1 !is String || value_1 == null) }
return !(this@case_26_1 == null || this@case_26_1 !is String || value_1 == null)
}
fun <T> T?.case_26_2(value_1: Int?): Boolean? {
contract { returnsNotNull() implies (this@case_26_2 == null || this@case_26_2 !is String || value_1 == null) }
return if (this@case_26_2 == null || this@case_26_2 !is String || value_1 == null) true else null
}
fun <T> T?.case_26_3(value_1: Int?): Boolean? {
contract { returns(null) implies (this@case_26_3 == null || this@case_26_3 !is String || value_1 == null) }
return if (this@case_26_3 == null || this@case_26_3 !is String || value_1 == null) null else true
}
// FILE: usages.kt
import contracts.*
fun case_1(value_1: Any?) {
if (!contracts.case_1(value_1)) println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>()) // no smartcast
}
fun case_2(value_1: Any?) {
if (!contracts.case_2(value_1)) println(value_1?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>()) // no smartcast
}
fun case_3(number: Int?) {
if (!funWithReturnsTrueAndNullCheck(number)) number<!UNSAFE_CALL!>.<!>inc() // nullable receiver
}
fun case_5(value_1: Any?) {
if (!funWithReturnsTrue(value_1 !is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_6(value_1: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalse(value_1 !is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalseAndInvertCondition(value_1 is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (!(funWithReturnsNotNullAndInvertCondition(value_1 !is String) != null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (!(funWithReturnsNullAndInvertCondition(value_1 !is String) == null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_7(value_1: Any?) {
if (!funWithReturnsTrue(value_1 == null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_8(value_1: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 != null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalse(value_1 == null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalseAndInvertCondition(value_1 != null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_9(value_1: Any?) {
if (!funWithReturnsTrueAndInvertTypeCheck(value_1)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalseAndInvertTypeCheck(value_1)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_10(value_1: Number?) {
if (!funWithReturnsTrueAndNullCheck(value_1)) println(value_1<!UNSAFE_CALL!>.<!>toByte())
if (funWithReturnsFalseAndNullCheck(value_1)) println(value_1<!UNSAFE_CALL!>.<!>toByte())
if (funWithReturnsFalseAndNotNullCheck(value_1)) println(value_1)
if (!(funWithReturnsNotNullAndNullCheck(value_1) != null)) println(value_1)
if (!(funWithReturnsNullAndNullCheck(value_1) == null)) println(value_1)
}
fun case_11(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 is String && value_2 is Number)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_12(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrue(value_1 !is String || value_2 !is Number)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalse(value_1 !is String || value_2 !is Number)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_13(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrue(value_1 !is String || value_2 != null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalse(value_1 !is Float? || value_1 == null || value_2 == null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNull(value_1 !is String || value_2 !is Number) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNull(value_1 !is String || value_2 !is Number) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_14(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 is Float? && value_1 != null && value_2 != null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalseAndInvertCondition(value_1 is String && value_2 is Number)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalseAndInvertCondition(value_1 is String && value_2 == null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNullAndInvertCondition(value_1 is String && value_2 is Number) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNullAndInvertCondition(value_1 is String && value_2 == null) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNull(value_1 is Float? && value_1 != null && value_2 != null) == null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNullAndInvertCondition(value_1 is String && value_2 is Number) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNullAndInvertCondition(value_1 is String && value_2 == null) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNull(value_1 is Float? && value_1 != null && value_2 != null) != null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
class case_15_class {
val prop_1: Int? = 10
fun case_15(value_1: Any?, value_2: Number?) {
val o = case_15_class()
if (!funWithReturnsTrueAndInvertCondition(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (funWithReturnsFalse(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (funWithReturnsNotNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) == null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (funWithReturnsNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) != null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
}
}
fun case_16(value_1: Any?, value_2: Any?) {
if (!contracts.case_16_1(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_16_2(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (!(contracts.case_16_3(value_1, value_2) != null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (!(contracts.case_16_4(value_1, value_2) == null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_17(value_1: Any?, value_2: Any?) {
if (!contracts.case_17_1(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_17_2(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_17_3(value_1, value_2) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_17_4(value_1, value_2) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
class case_18_class {
val prop_1: Int? = 10
fun case_18(value_1: Any?, value_2: Number?) {
val o = case_18_class()
if (contracts.case_18_1(value_1, value_2, o.prop_1, this.prop_1)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (contracts.case_18_2(value_1, value_2, o.prop_1, this.prop_1)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (contracts.case_18_3(value_1, value_2, o.prop_1, this.prop_1) == null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (contracts.case_18_4(value_1, value_2, o.prop_1, this.prop_1) != null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
}
}
fun case_19(value_1: Any?) {
if (!value_1.case_19_1()) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_19_2()) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_19_3() == null) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_19_4() != null) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_20(value_1: Number) {
when { !value_1.case_20_1() -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
when { value_1.case_20_2() -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
when { value_1.case_20_3() == null -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
when { value_1.case_20_4() != null -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
}
fun case_21(value_1: String?, value_2: String?, value_3: String?, value_4: String?) {
if (!value_1.case_21_1()) println(value_1)
if (!value_2.case_21_2()) println(value_2<!UNSAFE_CALL!>.<!>length)
when (value_3.case_21_3()) {
true -> println(value_4<!UNSAFE_CALL!>.<!>length)
false -> println(value_3)
}
}
fun case_22(value_1: String?) {
when { !value_1.case_22_1() -> println(value_1) }
when { !value_1.case_22_2() -> println(value_1<!UNSAFE_CALL!>.<!>length) }
when {
value_1.case_22_5() == null -> println(value_1<!UNSAFE_CALL!>.<!>length)
value_1.case_22_5() != null -> println(value_1)
}
when {
value_1.case_22_7() != null -> println(value_1<!UNSAFE_CALL!>.<!>length)
value_1.case_22_7() == null -> println(value_1)
}
}
fun case_23(value_1: Any?, value_2: Any?) {
when { value_1.case_23_1() -> println(value_1.<!UNRESOLVED_REFERENCE!>length<!>) }
when { value_2.case_23_2() == null -> println(value_2.<!UNRESOLVED_REFERENCE!>length<!>) }
when { value_2.case_23_3() != null -> println(value_2.<!UNRESOLVED_REFERENCE!>length<!>) }
}
fun case_24(value_1: Number?, value_2: Number?) {
if (value_1.case_24_1()) println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_24_2() == null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_24_3() != null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
}
fun case_25(value_1: Any?, value_2: Any?) {
if (value_1.case_25_1()) println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_25_2() != null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_25_3() == null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
}
fun case_26(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?) {
when {
value_1.case_26_1(value_2) -> {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2<!UNSAFE_CALL!>.<!>inv())
}
}
when {
value_3.case_26_2(value_4) == null -> {
println(value_3.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_4<!UNSAFE_CALL!>.<!>inv())
}
}
when {
value_3.case_26_3(value_4) != null -> {
println(value_3.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_4<!UNSAFE_CALL!>.<!>inv())
}
}
}
@@ -0,0 +1,276 @@
package
public fun case_1(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_10(/*0*/ value_1: kotlin.Number?): kotlin.Unit
public fun case_11(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_12(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_13(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_14(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_16(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_17(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_19(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_2(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_20(/*0*/ value_1: kotlin.Number): kotlin.Unit
public fun case_21(/*0*/ value_1: kotlin.String?, /*1*/ value_2: kotlin.String?, /*2*/ value_3: kotlin.String?, /*3*/ value_4: kotlin.String?): kotlin.Unit
public fun case_22(/*0*/ value_1: kotlin.String?): kotlin.Unit
public fun case_23(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_24(/*0*/ value_1: kotlin.Number?, /*1*/ value_2: kotlin.Number?): kotlin.Unit
public fun case_25(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_26(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Int?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Int?): kotlin.Unit
public fun case_3(/*0*/ number: kotlin.Int?): kotlin.Unit
public fun case_5(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_6(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_7(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_8(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_9(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public inline fun </*0*/ T> funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> T): T
CallsInPlace(block, AT_LEAST_ONCE)
public inline fun funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, AT_LEAST_ONCE)
public inline fun funWithAtMostOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, AT_MOST_ONCE)
public inline fun </*0*/ T> funWithExactlyOnceCallsInPlace(/*0*/ block: () -> T): T
CallsInPlace(block, EXACTLY_ONCE)
public inline fun funWithExactlyOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
public fun funWithReturns(/*0*/ cond: kotlin.Boolean): kotlin.Unit
Returns(WILDCARD) -> cond
public fun funWithReturnsAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Unit
Returns(WILDCARD) -> !cond
public fun funWithReturnsAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 !is String
public fun funWithReturnsAndNotNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 != null
public fun funWithReturnsAndNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 == null
public fun funWithReturnsAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> value_1 is String
public fun funWithReturnsFalse(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(FALSE) -> cond
public fun funWithReturnsFalseAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(FALSE) -> !cond
public fun funWithReturnsFalseAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is String
public fun funWithReturnsFalseAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean
Returns(FALSE) -> value_1 != null
public fun funWithReturnsFalseAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean
Returns(FALSE) -> value_1 == null
public fun funWithReturnsFalseAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 is String
public fun funWithReturnsNotNull(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NOT_NULL) -> cond
public fun funWithReturnsNotNullAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NOT_NULL) -> !cond
public fun funWithReturnsNotNullAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is String
public fun funWithReturnsNotNullAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 != null
public fun funWithReturnsNotNullAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 == null
public fun funWithReturnsNotNullAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 is String
public fun funWithReturnsNull(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NULL) -> cond
public fun funWithReturnsNullAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean?
Returns(NULL) -> !cond
public fun funWithReturnsNullAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is String
public fun funWithReturnsNullAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NULL) -> value_1 != null
public fun funWithReturnsNullAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean?
Returns(NULL) -> value_1 == null
public fun funWithReturnsNullAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 is String
public fun funWithReturnsTrue(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(TRUE) -> cond
public fun funWithReturnsTrueAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean
Returns(TRUE) -> !cond
public fun funWithReturnsTrueAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is String
public fun funWithReturnsTrueAndNotNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 != null
public fun funWithReturnsTrueAndNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 == null
public fun funWithReturnsTrueAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 is String
public inline fun funWithUnknownCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, UNKNOWN)
public final class case_15_class {
public constructor case_15_class()
public final val prop_1: kotlin.Int? = 10
public final fun case_15(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class case_18_class {
public constructor case_18_class()
public final val prop_1: kotlin.Int? = 10
public final fun case_18(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
package contracts {
public fun case_1(/*0*/ x: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> x !is Number
public fun case_16_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is String || value_2 !is Number
public fun case_16_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is String || value_2 !is Number
public fun case_16_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is String || value_2 !is Number
public fun case_16_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is String || value_2 !is Number
public fun case_17_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is String || value_2 != null
public fun case_17_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is String || value_2 != null
public fun case_17_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is String || value_2 != null
public fun case_17_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is String || value_2 != null
public fun case_18_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_18_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_18_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_18_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_2(/*0*/ x: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> x !is Number?
public fun </*0*/ T> T.case_19_1(): kotlin.Boolean
Returns(TRUE) -> <this> !is String
public fun </*0*/ T> T.case_19_2(): kotlin.Boolean
Returns(FALSE) -> <this> is String
public fun </*0*/ T> T.case_19_3(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> is String
public fun </*0*/ T> T.case_19_4(): kotlin.Boolean?
Returns(NULL) -> <this> is String
public fun </*0*/ T : kotlin.Number> T.case_20_1(): kotlin.Boolean
Returns(TRUE) -> <this> !is Int
public fun </*0*/ T : kotlin.Number> T.case_20_2(): kotlin.Boolean
Returns(FALSE) -> <this> is Int
public fun </*0*/ T : kotlin.Number> T.case_20_3(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> is Int
public fun </*0*/ T : kotlin.Number> T.case_20_4(): kotlin.Boolean?
Returns(NULL) -> <this> is Int
public fun </*0*/ T : kotlin.String> T?.case_21_1(): kotlin.Boolean
Returns(TRUE) -> <this> != null
public fun </*0*/ T : kotlin.String> T?.case_21_2(): kotlin.Boolean
Returns(TRUE) -> <this> == null
public fun </*0*/ T : kotlin.String> T?.case_21_3(): kotlin.Boolean
Returns(FALSE) -> <this> != null
public fun </*0*/ T : kotlin.String?> T.case_22_1(): kotlin.Boolean
Returns(TRUE) -> <this> != null
public fun </*0*/ T : kotlin.String?> T.case_22_2(): kotlin.Boolean
Returns(TRUE) -> <this> == null
public fun </*0*/ T : kotlin.String> T?.case_22_5(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> != null
public fun </*0*/ T : kotlin.String> T?.case_22_7(): kotlin.Boolean?
Returns(NULL) -> <this> != null
public fun </*0*/ T> T?.case_23_1(): kotlin.Boolean
Returns(FALSE) -> <this> == null || <this> !is String
public fun </*0*/ T> T?.case_23_2(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> == null || <this> !is String
public fun </*0*/ T> T?.case_23_3(): kotlin.Boolean?
Returns(NULL) -> <this> == null || <this> !is String
public fun </*0*/ T : kotlin.Number?> T.case_24_1(): kotlin.Boolean
Returns(FALSE) -> <this> !is Int || <this> == null
public fun </*0*/ T : kotlin.Number?> T.case_24_2(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> !is Int || <this> == null
public fun </*0*/ T : kotlin.Number?> T.case_24_3(): kotlin.Boolean?
Returns(NULL) -> <this> !is Int || <this> == null
public inline fun </*0*/ reified T> T?.case_25_1(): kotlin.Boolean
Returns(FALSE) -> <this> !is Number || <this> !is Int || <this> == null
public inline fun </*0*/ reified T> T?.case_25_2(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> !is Number || <this> !is Int || <this> == null
public inline fun </*0*/ reified T> T?.case_25_3(): kotlin.Boolean?
Returns(NULL) -> <this> !is Number || <this> !is Int || <this> == null
public fun </*0*/ T> T?.case_26_1(/*0*/ value_1: kotlin.Int?): kotlin.Boolean
Returns(FALSE) -> <this> == null || <this> !is String || value_1 == null
public fun </*0*/ T> T?.case_26_2(/*0*/ value_1: kotlin.Int?): kotlin.Boolean?
Returns(NOT_NULL) -> <this> == null || <this> !is String || value_1 == null
public fun </*0*/ T> T?.case_26_3(/*0*/ value_1: kotlin.Int?): kotlin.Boolean?
Returns(NULL) -> <this> == null || <this> !is String || value_1 == null
}
@@ -1,7 +1,7 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
// !WITH_CONTRACT_FUNCTIONS
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !WITH_CONTRACT_FUNCTIONS
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
@@ -9,9 +9,7 @@
SECTION: contracts
CATEGORIES: analysis, smartcasts
NUMBER: 11
DESCRIPTION: Check smartcasts using double negation (returnsFalse/invert type checking/not operator).
UNEXPECTED BEHAVIOUR
ISSUES: KT-26176
DESCRIPTION: Smartcast using many of the various Returns effects on the same values.
*/
// FILE: contracts.kt
@@ -20,181 +18,23 @@ package contracts
import kotlin.contracts.*
fun case_1(x: Any?): Boolean {
contract { returns(true) implies (x !is Number) }
return x !is Number
fun <T> T?.case_1_1(): Boolean {
contract { returns(false) implies (this@case_1_1 != null) }
return !(this@case_1_1 != null)
}
fun case_2(x: Any?): Boolean {
contract { returns(true) implies (x !is Number?) }
return x !is Number?
fun <T> T?.case_1_2(): Boolean? {
contract { returns(null) implies (this@case_1_2 is String) }
return if (this@case_1_2 is String) null else true
}
fun case_16_1(value_1: Any?, value_2: Any?): Boolean {
contract { returns(true) implies (value_1 !is String || value_2 !is Number) }
return value_1 !is String || value_2 !is Number
fun <T : Number?> T.case_2_1(): Boolean? {
contract { returnsNotNull() implies (this@case_2_1 != null) }
return if (this@case_2_1 != null) true else null
}
fun case_16_2(value_1: Any?, value_2: Any?): Boolean {
contract { returns(false) implies (value_1 !is String || value_2 !is Number) }
return !(value_1 !is String || value_2 !is Number)
}
fun case_16_3(value_1: Any?, value_2: Any?): Boolean? {
contract { returnsNotNull() implies (value_1 !is String || value_2 !is Number) }
return if (value_1 !is String || value_2 !is Number) true else null
}
fun case_16_4(value_1: Any?, value_2: Any?): Boolean? {
contract { returns(null) implies (value_1 !is String || value_2 !is Number) }
return if (value_1 !is String || value_2 !is Number) null else true
}
fun case_17_1(value_1: Any?, value_2: Any?): Boolean {
contract { returns(true) implies (value_1 !is String || value_2 != null) }
return value_1 !is String || value_2 != null
}
fun case_17_2(value_1: Any?, value_2: Any?): Boolean {
contract { returns(false) implies (value_1 !is String || value_2 != null) }
return !(value_1 !is String || value_2 != null)
}
fun case_17_3(value_1: Any?, value_2: Any?): Boolean? {
contract { returnsNotNull() implies (value_1 !is String || value_2 != null) }
return if (value_1 !is String || value_2 != null) true else null
}
fun case_17_4(value_1: Any?, value_2: Any?): Boolean? {
contract { returns(null) implies (value_1 !is String || value_2 != null) }
return if (value_1 !is String || value_2 != null) null else true
}
fun case_18_1(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean {
contract { returns(true) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
}
fun case_18_2(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean {
contract { returns(false) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return !(value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null)
}
fun case_18_3(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? {
contract { returnsNotNull() implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return if (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) true else null
}
fun case_18_4(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? {
contract { returns(null) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) }
return if (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) null else true
}
fun <T> T.case_19_1(): Boolean {
contract { returns(true) implies (this@case_19_1 !is String) }
return this@case_19_1 !is String
}
fun <T> T.case_19_2(): Boolean {
contract { returns(false) implies (this@case_19_2 is String) }
return !(this@case_19_2 is String)
}
fun <T> T.case_19_3(): Boolean? {
contract { returnsNotNull() implies (this@case_19_3 is String) }
return if (this@case_19_3 is String) true else null
}
fun <T> T.case_19_4(): Boolean? {
contract { returns(null) implies (this@case_19_4 is String) }
return if (this@case_19_4 is String) null else true
}
fun <T : Number> T.case_20_1(): Boolean {
contract { returns(true) implies (this@case_20_1 !is Int) }
return this@case_20_1 !is Int
}
fun <T : Number> T.case_20_2(): Boolean {
contract { returns(false) implies (this@case_20_2 is Int) }
return !(this@case_20_2 is Int)
}
fun <T : Number> T.case_20_3(): Boolean? {
contract { returnsNotNull() implies (this@case_20_3 is Int) }
return if (this@case_20_3 is Int) true else null
}
fun <T : Number> T.case_20_4(): Boolean? {
contract { returns(null) implies (this@case_20_4 is Int) }
return if (this@case_20_4 is Int) null else true
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_1(): Boolean {
contract { returns(true) implies (this@case_21_1 != null) }
return this@case_21_1 != null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_2(): Boolean {
contract { returns(true) implies (this@case_21_2 == null) }
return this@case_21_2 == null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_3(): Boolean {
contract { returns(false) implies (this@case_21_3 != null) }
return !(this@case_21_3 != null)
}
fun <T : String?> T.case_22_1(): Boolean {
contract { returns(true) implies (this@case_22_1 != null) }
return this@case_22_1 != null
}
fun <T : String?> T.case_22_2(): Boolean {
contract { returns(true) implies (this@case_22_2 == null) }
return this@case_22_2 == null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_22_5(): Boolean? {
contract { returnsNotNull() implies (this@case_22_5 != null) }
return if (this@case_22_5 != null) true else null
}
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_22_7(): Boolean? {
contract { returns(null) implies (this@case_22_7 != null) }
return if (this@case_22_7 != null) null else true
}
fun <T> T?.case_23_1(): Boolean {
contract { returns(false) implies (this@case_23_1 == null || this@case_23_1 !is String) }
return !(this@case_23_1 == null || this@case_23_1 !is String)
}
fun <T> T?.case_23_2(): Boolean? {
contract { returnsNotNull() implies (this@case_23_2 == null || this@case_23_2 !is String) }
return if (this@case_23_2 == null || this@case_23_2 !is String) true else null
}
fun <T> T?.case_23_3(): Boolean? {
contract { returns(null) implies (this@case_23_3 == null || this@case_23_3 !is String) }
return if (this@case_23_3 == null || this@case_23_3 !is String) null else true
}
fun <T : Number?> T.case_24_1(): Boolean {
contract { returns(false) implies (this@case_24_1 !is Int || <!SENSELESS_COMPARISON!>this@case_24_1 == null<!>) }
return !(this@case_24_1 !is Int || <!SENSELESS_COMPARISON!>this@case_24_1 == null<!>)
}
fun <T : Number?> T.case_24_2(): Boolean? {
contract { returnsNotNull() implies (this@case_24_2 !is Int || <!SENSELESS_COMPARISON!>this@case_24_2 == null<!>) }
return if (this@case_24_2 !is Int || <!SENSELESS_COMPARISON!>this@case_24_2 == null<!>) true else null
}
fun <T : Number?> T.case_24_3(): Boolean? {
contract { returns(null) implies (this@case_24_3 !is Int || <!SENSELESS_COMPARISON!>this@case_24_3 == null<!>) }
return if (this@case_24_3 !is Int || <!SENSELESS_COMPARISON!>this@case_24_3 == null<!>) null else true
}
inline fun <reified T : Any?> T?.case_25_1(): Boolean {
contract { returns(false) implies (this@case_25_1 !is Number || this@case_25_1 !is Int || <!SENSELESS_COMPARISON!>this@case_25_1 == null<!>) }
return !(this@case_25_1 !is Number || this@case_25_1 !is Int || <!SENSELESS_COMPARISON!>this@case_25_1 == null<!>)
}
inline fun <reified T : Any?> T?.case_25_2(): Boolean? {
contract { returnsNotNull() implies (this@case_25_2 !is Number || this@case_25_2 !is Int || <!SENSELESS_COMPARISON!>this@case_25_2 == null<!>) }
return if (this@case_25_2 !is Number || this@case_25_2 !is Int || <!SENSELESS_COMPARISON!>this@case_25_2 == null<!>) true else null
}
inline fun <reified T : Any?> T?.case_25_3(): Boolean? {
contract { returns(null) implies (this@case_25_3 !is Number || this@case_25_3 !is Int || <!SENSELESS_COMPARISON!>this@case_25_3 == null<!>) }
return if (this@case_25_3 !is Number || this@case_25_3 !is Int || <!SENSELESS_COMPARISON!>this@case_25_3 == null<!>) null else true
}
fun <T> T?.case_26_1(value_1: Int?): Boolean {
contract { returns(false) implies (this@case_26_1 == null || this@case_26_1 !is String || value_1 == null) }
return !(this@case_26_1 == null || this@case_26_1 !is String || value_1 == null)
}
fun <T> T?.case_26_2(value_1: Int?): Boolean? {
contract { returnsNotNull() implies (this@case_26_2 == null || this@case_26_2 !is String || value_1 == null) }
return if (this@case_26_2 == null || this@case_26_2 !is String || value_1 == null) true else null
}
fun <T> T?.case_26_3(value_1: Int?): Boolean? {
contract { returns(null) implies (this@case_26_3 == null || this@case_26_3 !is String || value_1 == null) }
return if (this@case_26_3 == null || this@case_26_3 !is String || value_1 == null) null else true
fun <T : Number?> T.case_2_2(): Boolean? {
contract { returns(null) implies (this@case_2_2 != null) }
return if (this@case_2_2 != null) null else true
}
// FILE: usages.kt
@@ -202,316 +42,13 @@ fun <T> T?.case_26_3(value_1: Int?): Boolean? {
import contracts.*
fun case_1(value_1: Any?) {
if (!contracts.case_1(value_1)) println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>()) // no smartcast
}
fun case_2(value_1: Any?) {
if (!contracts.case_2(value_1)) println(value_1?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>()) // no smartcast
}
fun case_3(number: Int?) {
if (!funWithReturnsTrueAndNullCheck(number)) number<!UNSAFE_CALL!>.<!>inc() // nullable receiver
}
fun case_5(value_1: Any?) {
if (!funWithReturnsTrue(value_1 !is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_6(value_1: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalse(value_1 !is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalseAndInvertCondition(value_1 is String)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (!(funWithReturnsNotNullAndInvertCondition(value_1 !is String) != null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (!(funWithReturnsNullAndInvertCondition(value_1 !is String) == null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_7(value_1: Any?) {
if (!funWithReturnsTrue(value_1 == null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_8(value_1: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 != null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalse(value_1 == null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalseAndInvertCondition(value_1 != null)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_9(value_1: Any?) {
if (!funWithReturnsTrueAndInvertTypeCheck(value_1)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalseAndInvertTypeCheck(value_1)) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_10(value_1: Number?) {
if (!funWithReturnsTrueAndNullCheck(value_1)) println(value_1<!UNSAFE_CALL!>.<!>toByte())
if (funWithReturnsFalseAndNullCheck(value_1)) println(value_1<!UNSAFE_CALL!>.<!>toByte())
if (funWithReturnsFalseAndNotNullCheck(value_1)) println(value_1)
if (!(funWithReturnsNotNullAndNullCheck(value_1) != null)) println(value_1)
if (!(funWithReturnsNullAndNullCheck(value_1) == null)) println(value_1)
}
fun case_11(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 is String && value_2 is Number)) {
if (!(value_1.case_1_1() || value_1.case_1_2() == null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_12(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrue(value_1 !is String || value_2 !is Number)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalse(value_1 !is String || value_2 !is Number)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_13(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrue(value_1 !is String || value_2 != null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalse(value_1 !is Float? || value_1 == null || value_2 == null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNull(value_1 !is String || value_2 !is Number) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNull(value_1 !is String || value_2 !is Number) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_14(value_1: Any?, value_2: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 is Float? && value_1 != null && value_2 != null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalseAndInvertCondition(value_1 is String && value_2 is Number)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsFalseAndInvertCondition(value_1 is String && value_2 == null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNullAndInvertCondition(value_1 is String && value_2 is Number) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNullAndInvertCondition(value_1 is String && value_2 == null) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNotNull(value_1 is Float? && value_1 != null && value_2 != null) == null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNullAndInvertCondition(value_1 is String && value_2 is Number) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNullAndInvertCondition(value_1 is String && value_2 == null) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (funWithReturnsNull(value_1 is Float? && value_1 != null && value_2 != null) != null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
class case_15_class {
val prop_1: Int? = 10
fun case_15(value_1: Any?, value_2: Number?) {
val o = case_15_class()
if (!funWithReturnsTrueAndInvertCondition(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (funWithReturnsFalse(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (funWithReturnsNotNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) == null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (funWithReturnsNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) != null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
}
}
fun case_16(value_1: Any?, value_2: Any?) {
if (!contracts.case_16_1(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_16_2(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (!(contracts.case_16_3(value_1, value_2) != null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (!(contracts.case_16_4(value_1, value_2) == null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
fun case_17(value_1: Any?, value_2: Any?) {
if (!contracts.case_17_1(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_17_2(value_1, value_2)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_17_3(value_1, value_2) == null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
if (contracts.case_17_4(value_1, value_2) != null) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2?.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
class case_18_class {
val prop_1: Int? = 10
fun case_18(value_1: Any?, value_2: Number?) {
val o = case_18_class()
if (contracts.case_18_1(value_1, value_2, o.prop_1, this.prop_1)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (contracts.case_18_2(value_1, value_2, o.prop_1, this.prop_1)) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (contracts.case_18_3(value_1, value_2, o.prop_1, this.prop_1) == null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
if (contracts.case_18_4(value_1, value_2, o.prop_1, this.prop_1) != null) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
println(value_2?.toByte())
println(o.prop_1<!UNSAFE_CALL!>.<!>plus(3))
println(this.prop_1<!UNSAFE_CALL!>.<!>plus(3))
}
}
}
fun case_19(value_1: Any?) {
if (!value_1.case_19_1()) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_19_2()) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_19_3() == null) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_19_4() != null) println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
fun case_20(value_1: Number) {
when { !value_1.case_20_1() -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
when { value_1.case_20_2() -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
when { value_1.case_20_3() == null -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
when { value_1.case_20_4() != null -> println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()) }
}
fun case_21(value_1: String?, value_2: String?, value_3: String?, value_4: String?) {
if (!value_1.case_21_1()) println(value_1)
if (!value_2.case_21_2()) println(value_2<!UNSAFE_CALL!>.<!>length)
when (value_3.case_21_3()) {
true -> println(value_4<!UNSAFE_CALL!>.<!>length)
false -> println(value_3)
}
}
fun case_22(value_1: String?) {
when { !value_1.case_22_1() -> println(value_1) }
when { !value_1.case_22_2() -> println(value_1<!UNSAFE_CALL!>.<!>length) }
when {
value_1.case_22_5() == null -> println(value_1<!UNSAFE_CALL!>.<!>length)
value_1.case_22_5() != null -> println(value_1)
}
when {
value_1.case_22_7() != null -> println(value_1<!UNSAFE_CALL!>.<!>length)
value_1.case_22_7() == null -> println(value_1)
}
}
fun case_23(value_1: Any?, value_2: Any?) {
when { value_1.case_23_1() -> println(value_1.<!UNRESOLVED_REFERENCE!>length<!>) }
when { value_2.case_23_2() == null -> println(value_2.<!UNRESOLVED_REFERENCE!>length<!>) }
when { value_2.case_23_3() != null -> println(value_2.<!UNRESOLVED_REFERENCE!>length<!>) }
}
fun case_24(value_1: Number?, value_2: Number?) {
if (value_1.case_24_1()) println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_24_2() == null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_24_3() != null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
}
fun case_25(value_1: Any?, value_2: Any?) {
if (value_1.case_25_1()) println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_25_2() != null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
if (value_2.case_25_3() == null) println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>())
}
fun case_26(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?) {
when {
value_1.case_26_1(value_2) -> {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2<!UNSAFE_CALL!>.<!>inv())
}
}
when {
value_3.case_26_2(value_4) == null -> {
println(value_3.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_4<!UNSAFE_CALL!>.<!>inv())
}
}
when {
value_3.case_26_3(value_4) != null -> {
println(value_3.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_4<!UNSAFE_CALL!>.<!>inv())
}
}
}
/*
UNEXPECTED BEHAVIOUR
*/
fun case_27(value_1: Any?, value_2: Any?, value_3: Any?) {
funWithReturnsAndInvertCondition(value_1 !is String? || value_2 !is Number && value_3 !is Float)
println(<!DEBUG_INFO_SMARTCAST!>value_1<!>!!.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
println(value_3.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
}
/*
UNEXPECTED BEHAVIOUR
*/
fun case_28(value_1: Any?, value_2: Any?, value_3: Any?) {
funWithReturnsAndInvertCondition(value_1 !is String || value_2 !is Number || <!USELESS_IS_CHECK!>value_3 !is Any?<!>)
println(<!DEBUG_INFO_SMARTCAST!>value_1<!><!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.<!UNRESOLVED_REFERENCE!>length<!>)
println(<!DEBUG_INFO_SMARTCAST!>value_2<!><!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
println(value_3.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
}
// DISCUSSION: maybe make unreachable code in the second condition?
fun case_2(value_1: Number?) {
if (value_1?.case_2_1() != null) println(<!DEBUG_INFO_SMARTCAST!>value_1<!>.toByte())
if (value_1?.case_2_2() != null) println(<!DEBUG_INFO_SMARTCAST!>value_1<!>.toByte())
}
@@ -1,30 +1,7 @@
package
public fun case_1(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_10(/*0*/ value_1: kotlin.Number?): kotlin.Unit
public fun case_11(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_12(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_13(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_14(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_16(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_17(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_19(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_2(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_20(/*0*/ value_1: kotlin.Number): kotlin.Unit
public fun case_21(/*0*/ value_1: kotlin.String?, /*1*/ value_2: kotlin.String?, /*2*/ value_3: kotlin.String?, /*3*/ value_4: kotlin.String?): kotlin.Unit
public fun case_22(/*0*/ value_1: kotlin.String?): kotlin.Unit
public fun case_23(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_24(/*0*/ value_1: kotlin.Number?, /*1*/ value_2: kotlin.Number?): kotlin.Unit
public fun case_25(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit
public fun case_26(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Int?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Int?): kotlin.Unit
public fun case_27(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?): kotlin.Unit
public fun case_28(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?): kotlin.Unit
public fun case_3(/*0*/ number: kotlin.Int?): kotlin.Unit
public fun case_5(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_6(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_7(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_8(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_9(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_2(/*0*/ value_1: kotlin.Number?): kotlin.Unit
public inline fun </*0*/ T> funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> T): T
CallsInPlace(block, AT_LEAST_ONCE)
@@ -133,146 +110,17 @@ public fun funWithReturnsTrueAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Bo
public inline fun funWithUnknownCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, UNKNOWN)
public final class case_15_class {
public constructor case_15_class()
public final val prop_1: kotlin.Int? = 10
public final fun case_15(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class case_18_class {
public constructor case_18_class()
public final val prop_1: kotlin.Int? = 10
public final fun case_18(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
package contracts {
public fun case_1(/*0*/ x: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> x !is Number
public fun case_16_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is String || value_2 !is Number
public fun case_16_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is String || value_2 !is Number
public fun case_16_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is String || value_2 !is Number
public fun case_16_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is String || value_2 !is Number
public fun case_17_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is String || value_2 != null
public fun case_17_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is String || value_2 != null
public fun case_17_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is String || value_2 != null
public fun case_17_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is String || value_2 != null
public fun case_18_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_18_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean
Returns(FALSE) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_18_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean?
Returns(NOT_NULL) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_18_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean?
Returns(NULL) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null
public fun case_2(/*0*/ x: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> x !is Number?
public fun </*0*/ T> T.case_19_1(): kotlin.Boolean
Returns(TRUE) -> <this> !is String
public fun </*0*/ T> T.case_19_2(): kotlin.Boolean
Returns(FALSE) -> <this> is String
public fun </*0*/ T> T.case_19_3(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> is String
public fun </*0*/ T> T.case_19_4(): kotlin.Boolean?
Returns(NULL) -> <this> is String
public fun </*0*/ T : kotlin.Number> T.case_20_1(): kotlin.Boolean
Returns(TRUE) -> <this> !is Int
public fun </*0*/ T : kotlin.Number> T.case_20_2(): kotlin.Boolean
Returns(FALSE) -> <this> is Int
public fun </*0*/ T : kotlin.Number> T.case_20_3(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> is Int
public fun </*0*/ T : kotlin.Number> T.case_20_4(): kotlin.Boolean?
Returns(NULL) -> <this> is Int
public fun </*0*/ T : kotlin.String> T?.case_21_1(): kotlin.Boolean
Returns(TRUE) -> <this> != null
public fun </*0*/ T : kotlin.String> T?.case_21_2(): kotlin.Boolean
Returns(TRUE) -> <this> == null
public fun </*0*/ T : kotlin.String> T?.case_21_3(): kotlin.Boolean
public fun </*0*/ T> T?.case_1_1(): kotlin.Boolean
Returns(FALSE) -> <this> != null
public fun </*0*/ T : kotlin.String?> T.case_22_1(): kotlin.Boolean
Returns(TRUE) -> <this> != null
public fun </*0*/ T> T?.case_1_2(): kotlin.Boolean?
Returns(NULL) -> <this> is String
public fun </*0*/ T : kotlin.String?> T.case_22_2(): kotlin.Boolean
Returns(TRUE) -> <this> == null
public fun </*0*/ T : kotlin.String> T?.case_22_5(): kotlin.Boolean?
public fun </*0*/ T : kotlin.Number?> T.case_2_1(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> != null
public fun </*0*/ T : kotlin.String> T?.case_22_7(): kotlin.Boolean?
public fun </*0*/ T : kotlin.Number?> T.case_2_2(): kotlin.Boolean?
Returns(NULL) -> <this> != null
public fun </*0*/ T> T?.case_23_1(): kotlin.Boolean
Returns(FALSE) -> <this> == null || <this> !is String
public fun </*0*/ T> T?.case_23_2(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> == null || <this> !is String
public fun </*0*/ T> T?.case_23_3(): kotlin.Boolean?
Returns(NULL) -> <this> == null || <this> !is String
public fun </*0*/ T : kotlin.Number?> T.case_24_1(): kotlin.Boolean
Returns(FALSE) -> <this> !is Int || <this> == null
public fun </*0*/ T : kotlin.Number?> T.case_24_2(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> !is Int || <this> == null
public fun </*0*/ T : kotlin.Number?> T.case_24_3(): kotlin.Boolean?
Returns(NULL) -> <this> !is Int || <this> == null
public inline fun </*0*/ reified T> T?.case_25_1(): kotlin.Boolean
Returns(FALSE) -> <this> !is Number || <this> !is Int || <this> == null
public inline fun </*0*/ reified T> T?.case_25_2(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> !is Number || <this> !is Int || <this> == null
public inline fun </*0*/ reified T> T?.case_25_3(): kotlin.Boolean?
Returns(NULL) -> <this> !is Number || <this> !is Int || <this> == null
public fun </*0*/ T> T?.case_26_1(/*0*/ value_1: kotlin.Int?): kotlin.Boolean
Returns(FALSE) -> <this> == null || <this> !is String || value_1 == null
public fun </*0*/ T> T?.case_26_2(/*0*/ value_1: kotlin.Int?): kotlin.Boolean?
Returns(NOT_NULL) -> <this> == null || <this> !is String || value_1 == null
public fun </*0*/ T> T?.case_26_3(/*0*/ value_1: kotlin.Int?): kotlin.Boolean?
Returns(NULL) -> <this> == null || <this> !is String || value_1 == null
}
@@ -151,3 +151,10 @@ class case_10_class {
}
}
}
fun case_11(value_1: Any?, value_2: Any?, value_3: Any?) {
funWithReturnsAndInvertCondition(value_1 !is String? || value_2 !is Number && value_3 !is Float)
println(<!DEBUG_INFO_SMARTCAST!>value_1<!>!!.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_2.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
println(value_3.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>dec<!>())
}
@@ -9,29 +9,27 @@
SECTION: contracts
CATEGORIES: analysis, smartcasts
NUMBER: 9
DESCRIPTION: Smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'exactly once' or 'at least once' CallsInPlace effects.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26148
DESCRIPTION: Check the lack of smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'unknown' or 'at most once' CallsInPlace effects.
*/
fun case_1(arg: Int?) {
funWithExactlyOnceCallsInPlace { arg!! }
funWithAtMostOnceCallsInPlace { arg!! }
arg<!UNSAFE_CALL!>.<!>inc()
}
fun case_2(arg: Int?) {
funWithAtLeastOnceCallsInPlace { arg!! }
funWithUnknownCallsInPlace { arg!! }
arg<!UNSAFE_CALL!>.<!>inc()
}
fun case_3() {
val value_1: Boolean?
funWithExactlyOnceCallsInPlace { value_1 = false }
value_1<!UNSAFE_CALL!>.<!>not()
funWithAtMostOnceCallsInPlace { value_1 = false }
<!UNINITIALIZED_VARIABLE!>value_1<!><!UNSAFE_CALL!>.<!>not()
}
fun case_4() {
val value_1: Boolean?
funWithAtLeastOnceCallsInPlace { <!VAL_REASSIGNMENT!>value_1<!> = true }
value_1<!UNSAFE_CALL!>.<!>not()
funWithUnknownCallsInPlace { <!VAL_REASSIGNMENT!>value_1<!> = true }
<!UNINITIALIZED_VARIABLE!>value_1<!><!UNSAFE_CALL!>.<!>not()
}
@@ -0,0 +1,37 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !WITH_CONTRACT_FUNCTIONS
// SKIP_TXT
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts
CATEGORIES: analysis, smartcasts
NUMBER: 12
DESCRIPTION: Smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'exactly once' or 'at least once' CallsInPlace effects.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26148
*/
fun case_1(arg: Int?) {
funWithExactlyOnceCallsInPlace { arg!! }
arg<!UNSAFE_CALL!>.<!>inc()
}
fun case_2(arg: Int?) {
funWithAtLeastOnceCallsInPlace { arg!! }
arg<!UNSAFE_CALL!>.<!>inc()
}
fun case_3() {
val value_1: Boolean?
funWithExactlyOnceCallsInPlace { value_1 = false }
value_1<!UNSAFE_CALL!>.<!>not()
}
fun case_4() {
val value_1: Boolean?
funWithAtLeastOnceCallsInPlace { <!VAL_REASSIGNMENT!>value_1<!> = true }
value_1<!UNSAFE_CALL!>.<!>not()
}
@@ -0,0 +1,44 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts
CATEGORIES: analysis, smartcasts
NUMBER: 13
DESCRIPTION: Check smartcast to upper bound of the types in disjunction.
UNEXPECTED BEHAVIOUR
ISSUES: KT-1982
*/
// FILE: contracts.kt
package contracts
import kotlin.contracts.*
fun <T : Any?> T?.case_1() {
contract { returns() implies (this@case_1 is Number || this@case_1 is Int) }
if (!(this@case_1 is Number || this@case_1 is Int)) throw Exception()
}
inline fun <reified T : Any?> T?.case_2(value_2: Number, value_3: Any?, value_4: String?) {
contract { returns() implies ((this@case_2 is Number || this@case_2 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) }
if (!((this is Number || this is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null)) throw Exception()
}
// FILE: usages.kt
import contracts.*
fun case_1(value_1: Any?) {
value_1.case_1()
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
fun case_2(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) {
value_1.case_2(value_2, value_3, value_4)
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
@@ -0,0 +1,13 @@
package
public fun case_1(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.String?): kotlin.Unit
package contracts {
public fun </*0*/ T> T?.case_1(): kotlin.Unit
Returns(WILDCARD) -> <this> is Number || <this> is Int
public inline fun </*0*/ reified T> T?.case_2(/*0*/ value_2: kotlin.Number, /*1*/ value_3: kotlin.Any?, /*2*/ value_4: kotlin.String?): kotlin.Unit
Returns(WILDCARD) -> (<this> is Number || <this> is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null
}
@@ -151,3 +151,14 @@ class case_10_class {
}
}
}
/*
CASE DESCRIPTION: check resolve reference when is used not null assertion and safe call operators
UNEXPECTED BEHAVIOUR
ISSUES: KT-26747
*/
fun case_12(value_1: Any?, value_2: Any?, value_3: Any?) {
funWithReturnsAndInvertCondition(value_1 !is String || value_2 !is Number || <!USELESS_IS_CHECK!>value_3 !is Any?<!>)
println(<!DEBUG_INFO_SMARTCAST!>value_1<!><!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.<!UNRESOLVED_REFERENCE!>length<!>)
println(<!DEBUG_INFO_SMARTCAST!>value_2<!><!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
}
@@ -141,13 +141,14 @@ fun <T : String?> T.case_8_4(): Boolean? {
return if (this@case_8_4 == null) null else true
}
fun <T : Number?> T.case_9_1(): Boolean? {
contract { returnsNotNull() implies (this@case_9_1 != null) }
return if (this@case_9_1 != null) true else null
fun <T> T?.case_9_1(): Boolean {
contract { returns(true) implies (this@case_9_1 is Float) }
return this@case_9_1 is Float
}
fun <T : Number?> T.case_9_2(): Boolean? {
contract { returns(null) implies (this@case_9_2 != null) }
return if (this@case_9_2 != null) null else true
fun <T> T?.case_9_2(): Boolean {
contract { returns(false) implies (this@case_9_2 is Double) }
return !(this@case_9_2 is Double)
}
// FILE: usages.kt
@@ -231,10 +232,12 @@ fun case_8(value_1: String?, value_2: String?) {
}
/*
CASE DESCRIPTION: check the infererence of the Number super type
UNEXPECTED BEHAVIOUR
KT-26382
ISSUES: KT-1982
*/
fun case_9(value_1: Number?) {
if (value_1?.case_9_1() != null) println(<!DEBUG_INFO_SMARTCAST!>value_1<!>.toByte())
if (value_1?.case_9_2() != null) println(<!DEBUG_INFO_SMARTCAST!>value_1<!>.toByte())
fun case_9(value_1: Any?) {
if (value_1.case_9_1() || !value_1.case_9_2()) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}
@@ -8,7 +8,7 @@ public fun case_5(/*0*/ value_1: kotlin.Any?): kotlin.Unit
public fun case_6(/*0*/ value_1: kotlin.Number): kotlin.Unit
public fun case_7(/*0*/ value_1: kotlin.String?): kotlin.Unit
public fun case_8(/*0*/ value_1: kotlin.String?, /*1*/ value_2: kotlin.String?): kotlin.Unit
public fun case_9(/*0*/ value_1: kotlin.Number?): kotlin.Unit
public fun case_9(/*0*/ value_1: kotlin.Any?): kotlin.Unit
package contracts {
public fun </*0*/ T> T.case_1(): kotlin.Unit
@@ -98,10 +98,10 @@ package contracts {
public fun </*0*/ T : kotlin.String?> T.case_8_4(): kotlin.Boolean?
Returns(NULL) -> <this> == null
public fun </*0*/ T : kotlin.Number?> T.case_9_1(): kotlin.Boolean?
Returns(NOT_NULL) -> <this> != null
public fun </*0*/ T> T?.case_9_1(): kotlin.Boolean
Returns(TRUE) -> <this> is Float
public fun </*0*/ T : kotlin.Number?> T.case_9_2(): kotlin.Boolean?
Returns(NULL) -> <this> != null
public fun </*0*/ T> T?.case_9_2(): kotlin.Boolean
Returns(FALSE) -> <this> is Double
}
@@ -103,6 +103,7 @@ fun case_4(value_1: Number, value_2: (() -> Unit)?) {
}
/*
CASE DESCRIPTION: check the conclusion that not-null conditions corresponds to the contract with not null effect
UNEXPECTED BEHAVIOUR: unsafe calls
ISSUES: KT-26612
*/
@@ -120,6 +121,7 @@ fun case_5(value_1: Number?, value_2: String?) {
}
/*
CASE DESCRIPTION: check the conclusion that not-null conditions corresponds to the contract with not null effect (with null branch)
UNEXPECTED BEHAVIOUR: unsafe calls
ISSUES: KT-26612
*/
@@ -101,9 +101,6 @@ fun case_8(value_1: Any?) {
}
}
/*
UNEXPECTED BEHAVIOUR: unreachable code
*/
fun case_9(value_1: Any?) {
if (funWithReturnsFalse(value_1 is String) || funWithReturnsFalse(value_1 is Int)) {
@@ -113,9 +110,6 @@ fun case_9(value_1: Any?) {
}
}
/*
UNEXPECTED BEHAVIOUR: unreachable code
*/
fun case_10(value_1: Any?) {
if (funWithReturnsFalse(value_1 is String) || getBoolean()) {
@@ -0,0 +1,58 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !WITH_FUNCTIONS
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts
CATEGORIES: declarations, contractBuilder, common
NUMBER: 14
DESCRIPTION: Contract is first statement in control flow terms, but not in tokens order terms.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26153
*/
import kotlin.contracts.*
internal inline fun case_1(block: () -> Unit) {
return contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
}
fun case_2() = contract { }
inline fun case_3(block: () -> Unit) {
val value_1 = contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
inline fun case_4(block: () -> Unit) {
(contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
})
return block()
}
inline fun case_5(block: () -> Unit) {
<!REDUNDANT_LABEL_WARNING!>test@<!> contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}
inline fun case_6(block: () -> Unit) {
throw Exception(contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}.toString())
}
inline fun case_7(block: () -> Unit) {
_funWithAnyArg(contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
})
}
@@ -0,0 +1,11 @@
package
public fun _funWithAnyArg(/*0*/ value_1: kotlin.Any): kotlin.Int
public fun _funWithoutArgs(): kotlin.Int
internal inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public fun case_2(): kotlin.Unit
public inline fun case_3(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_4(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_5(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_6(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_7(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
@@ -3,12 +3,12 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts
CATEGORY: declarations, contractBuilder, common
NUMBER: 5
DESCRIPTION: contracts with not allowed conditions with boolean constants or constant expressions in implies.
CATEGORIES: declarations, contractBuilder, common
NUMBER: 15
DESCRIPTION: contracts with not allowed conditions with boolean constants or boolean constant expressions in implies.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26491
*/
@@ -0,0 +1,54 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts
CATEGORIES: declarations, contractBuilder, common
NUMBER: 16
DESCRIPTION: Contract isn't in the first position.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26191
*/
import kotlin.contracts.*
fun case_1(value_1: Int?) {
println("!")
contract {
returns(true) implies (value_1 != null)
} <!CAST_NEVER_SUCCEEDS!>as<!> ContractBuilder
}
fun case_2(value_1: Int?) {
100 + 10
throw Exception(contract {
returns(true) implies (value_1 != null)
}.toString())
}
fun case_3(value_1: Int?) {
for (i in 0..10) {
println(i)
}
return contract {
returns(true) implies (value_1 != null)
}
}
fun case_4(value_1: Int?) {
val f = 10 - 20
val g = contract {
returns(true) implies (value_1 != null)
}
}
fun case_5(number: Int?): Boolean {
val value_1 = number != null
contract {
returns(false) implies (value_1)
} <!CAST_NEVER_SUCCEEDS!>as<!> ContractBuilder
return number == null
}
@@ -0,0 +1,7 @@
package
public fun case_1(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_2(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_3(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_4(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_5(/*0*/ number: kotlin.Int?): kotlin.Boolean
@@ -0,0 +1,31 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE -UNUSED_PARAMETER -UNREACHABLE_CODE -UNUSED_EXPRESSION
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts
CATEGORIES: declarations, contractBuilder, common
NUMBER: 17
DESCRIPTION: contracts with Nothing expressions in implies.
DISCUSSION
ISSUES: KT-25948
*/
import kotlin.contracts.*
fun case_1(): Boolean {
<!ERROR_IN_CONTRACT_DESCRIPTION!>contract<!> { returns(null) implies throw Exception() }
return true
}
fun case_2(): Boolean {
<!ERROR_IN_CONTRACT_DESCRIPTION!>contract<!> { returns(null) implies return return return false }
return true
}
fun case_3(): Boolean {
<!ERROR_IN_CONTRACT_DESCRIPTION!>contract<!> { returns(null) implies return return return false && throw throw throw throw Exception() }
return true
}
@@ -0,0 +1,5 @@
package
public fun case_1(): kotlin.Boolean
public fun case_2(): kotlin.Boolean
public fun case_3(): kotlin.Boolean
@@ -19,7 +19,7 @@ fun case_1(): Boolean {
}
fun case_2(): Boolean {
contract { returnsNotNull() implies (return return <!RETURN_TYPE_MISMATCH!>return<!>) }
contract { returnsNotNull() implies (return return return true) }
return true
}
@@ -28,30 +28,21 @@ fun case_3(): Boolean {
return true
}
/*
UNEXPECTED BEHAVIOUR
ISSUES: KT-25948
*/
fun case_4(): Boolean {
contract { returns(null) implies throw Exception() }
return true
}
/*
UNEXPECTED BEHAVIOUR
ISSUES: KT-26386
*/
fun case_5(): Boolean? {
contract { returns(null) implies case_5() }
fun case_4(): Boolean? {
contract { returns(null) implies case_4() }
return null
}
fun case_6(): Boolean? {
fun case_5(): Boolean? {
contract { returns(null) implies <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ERROR_IN_CONTRACT_DESCRIPTION!>listOf(0)<!> }
return null
}
fun case_7(value_1: Boolean): Boolean? {
fun case_6(value_1: Boolean): Boolean? {
contract { returns(null) implies <!TYPE_MISMATCH, ERROR_IN_CONTRACT_DESCRIPTION!>contract { returns(null) implies (!value_1) }<!> }
return null
}
@@ -1,7 +1,6 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// !WITH_FUNCTIONS
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
@@ -9,50 +8,17 @@
SECTION: contracts
CATEGORIES: declarations, contractBuilder, common
NUMBER: 2
DESCRIPTION: Contract is first statement in control flow terms, but not in tokens order terms.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26153
DESCRIPTION: Functions with contract and builder lambda in parentheses.
*/
import kotlin.contracts.*
internal inline fun case_1(block: () -> Unit) {
return contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
}
fun case_2() = contract { }
inline fun case_3(block: () -> Unit) {
val value_1 = contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
inline fun case_4(block: () -> Unit) {
(contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
})
inline fun case_1(block: () -> Unit) {
contract({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
return block()
}
inline fun case_5(block: () -> Unit) {
<!REDUNDANT_LABEL_WARNING!>test@<!> contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
inline fun case_2(block: () -> Unit) {
contract(builder = { callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
return block()
}
inline fun case_6(block: () -> Unit) {
throw Exception(contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}.toString())
}
inline fun case_7(block: () -> Unit) {
_funWithAnyArg(contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
})
}
@@ -1,11 +1,8 @@
package
public fun _funWithAnyArg(/*0*/ value_1: kotlin.Any): kotlin.Int
public fun _funWithoutArgs(): kotlin.Int
internal inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public fun case_2(): kotlin.Unit
public inline fun case_3(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_4(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_5(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_6(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_7(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
public inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
@@ -1,5 +1,5 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
@@ -8,17 +8,47 @@
SECTION: contracts
CATEGORIES: declarations, contractBuilder, common
NUMBER: 3
DESCRIPTION: Functions with contract and builder lambda in parentheses.
DESCRIPTION: Contract isn't in the first position.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26191
*/
import kotlin.contracts.*
inline fun case_1(block: () -> Unit) {
contract({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
return block()
fun case_1(value_1: Int?) {
println("!")
contract {
returns(true) implies (value_1 != null)
} <!CAST_NEVER_SUCCEEDS!>as<!> ContractBuilder
}
inline fun case_2(block: () -> Unit) {
contract(builder = { callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
return block()
fun case_2(value_1: Int?) {
100 + 10
throw Exception(contract {
returns(true) implies (value_1 != null)
}.toString())
}
fun case_3(value_1: Int?) {
for (i in 0..10) {
println(i)
}
return contract {
returns(true) implies (value_1 != null)
}
}
fun case_4(value_1: Int?) {
val f = 10 - 20
val g = contract {
returns(true) implies (value_1 != null)
}
}
fun case_5(number: Int?): Boolean {
val value_1 = number != null
contract {
returns(false) implies (value_1)
} <!CAST_NEVER_SUCCEEDS!>as<!> ContractBuilder
return number == null
}
@@ -1,8 +1,7 @@
package
public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
public inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
public fun case_1(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_2(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_3(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_4(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_5(/*0*/ number: kotlin.Int?): kotlin.Boolean
@@ -1,5 +1,5 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE -UNUSED_PARAMETER -UNREACHABLE_CODE -UNUSED_EXPRESSION
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
@@ -8,47 +8,19 @@
SECTION: contracts
CATEGORIES: declarations, contractBuilder, common
NUMBER: 4
DESCRIPTION: Contract isn't in the first position.
DESCRIPTION: contracts with not allowed conditions with boolean constants or constant expressions in implies.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26191
ISSUES: KT-26491
*/
import kotlin.contracts.*
fun case_1(value_1: Int?) {
println("!")
contract {
returns(true) implies (value_1 != null)
} <!CAST_NEVER_SUCCEEDS!>as<!> ContractBuilder
fun case_1(): Boolean {
contract { returns(true) implies true }
return true
}
fun case_2(value_1: Int?) {
100 + 10
throw Exception(contract {
returns(true) implies (value_1 != null)
}.toString())
}
fun case_3(value_1: Int?) {
for (i in 0..10) {
println(i)
}
return contract {
returns(true) implies (value_1 != null)
}
}
fun case_4(value_1: Int?) {
val f = 10 - 20
val g = contract {
returns(true) implies (value_1 != null)
}
}
fun case_5(number: Int?): Boolean {
val value_1 = number != null
contract {
returns(false) implies (value_1)
} <!CAST_NEVER_SUCCEEDS!>as<!> ContractBuilder
return number == null
}
fun case_2(): Boolean {
contract { returns(true) implies (true || false) }
return true || false
}
@@ -1,7 +1,7 @@
package
public fun case_1(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_2(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_3(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_4(/*0*/ value_1: kotlin.Int?): kotlin.Unit
public fun case_5(/*0*/ number: kotlin.Int?): kotlin.Boolean
public fun case_1(): kotlin.Boolean
Returns(TRUE) -> TRUE
public fun case_2(): kotlin.Boolean
Returns(TRUE) -> TRUE || FALSE
@@ -0,0 +1,32 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts
CATEGORIES: declarations, contractBuilder, effects, callsInPlace
NUMBER: 2
DESCRIPTION: functions with contract and duplicate CallsInPlace.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26150
*/
import kotlin.contracts.*
inline fun case_1(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}
inline fun case_2(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
}
return block()
}
@@ -0,0 +1,9 @@
package
public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
CallsInPlace(block, EXACTLY_ONCE)
public inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
CallsInPlace(block, AT_MOST_ONCE)
@@ -1,5 +1,5 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -UNUSED_VARIABLE
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
@@ -8,25 +8,19 @@
SECTION: contracts
CATEGORIES: declarations, contractBuilder, effects, callsInPlace
NUMBER: 2
DESCRIPTION: functions with contract and duplicate CallsInPlace.
DESCRIPTION: Contract with 'this' in first parameter of CallsInPlace.
DISCUSSION
UNEXPECTED BEHAVIOUR
ISSUES: KT-26150
ISSUES: KT-26294
*/
import kotlin.contracts.*
inline fun case_1(block: () -> Unit) {
inline fun <T : Function0<*>> T.case_1(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
callsInPlace(this@case_1, InvocationKind.EXACTLY_ONCE)
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}
inline fun case_2(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
}
return block()
block()
this@case_1()
}
@@ -1,9 +1,6 @@
package
public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
public inline fun </*0*/ T : kotlin.Function0<*>> T.case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(<this>, EXACTLY_ONCE)
CallsInPlace(block, EXACTLY_ONCE)
public inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
CallsInPlace(block, AT_MOST_ONCE)
@@ -42,10 +42,7 @@ object case_3 {
}
}
/*
UNEXPECTED BEHAVIOUR
ISSUES: KT-26244
*/
// ISSUES: KT-26244
class case_4 : _ClassLevel3() {
fun <T : Number?>T.case_4_1(): Boolean {
<!CONTRACT_NOT_ALLOWED!>contract<!> { returns(false) implies (<!USELESS_IS_CHECK!>this@case_4 !is _ClassLevel1<!>) }
@@ -79,10 +76,7 @@ class case_4 : _ClassLevel3() {
fun case_4_5() = _ClassLevel3().case_4_5_wrap()
}
/*
UNEXPECTED BEHAVIOUR
ISSUES: KT-26244
*/
// ISSUES: KT-26244
class case_5<T> : _ClassLevel5() {
inner class case_5_1 {
fun <K : Number?>K.case_5_1_1() {
@@ -0,0 +1,27 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
/*
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts
CATEGORIES: declarations, contractFunction
NUMBER: 3
DESCRIPTION: Check that fun with contract and CallsInPlace effect is an inline function.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26126
*/
import kotlin.contracts.*
fun funWithContractExactlyOnce(block: () -> Unit) { // report about not-inline function is expected
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
return block()
}
fun case_1() {
val value_1: Int
funWithContractExactlyOnce { value_1 = 10 } // back-end exception
value_1.inc()
}
@@ -0,0 +1,5 @@
package
public fun case_1(): kotlin.Unit
public fun funWithContractExactlyOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
@@ -1,4 +1,4 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
@@ -8,20 +8,30 @@
SECTION: contracts
CATEGORIES: declarations, contractFunction
NUMBER: 1
DESCRIPTION: Check that fun with contract and CallsInPlace effect is an inline function.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26126
DESCRIPTION: Contract function usage before declaration it
*/
import kotlin.contracts.*
fun funWithContractExactlyOnce(block: () -> Unit) { // report about not-inline function is expected
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
return block()
fun case_1_1(x: Any?) {
if (case_1_2(x)) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
}
fun case_1() {
val value_1: Int
funWithContractExactlyOnce { value_1 = 10 } // back-end exception
value_1.inc()
fun case_2_1(x: Number?) {
case_2_2(x)
println(<!DEBUG_INFO_SMARTCAST!>x<!>.toByte())
}
fun case_1_2(x: Any?): Boolean {
contract { returns(true) implies (x is String) }
return x is String
}
fun case_2_2(x: Any?) {
contract { returns() implies(x != null) }
if (x == null) throw Exception()
}
@@ -1,5 +1,10 @@
package
public fun case_1(): kotlin.Unit
public fun funWithContractExactlyOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
CallsInPlace(block, EXACTLY_ONCE)
public fun case_1_1(/*0*/ x: kotlin.Any?): kotlin.Unit
public fun case_1_2(/*0*/ x: kotlin.Any?): kotlin.Boolean
Returns(TRUE) -> x is String
public fun case_2_1(/*0*/ x: kotlin.Number?): kotlin.Unit
public fun case_2_2(/*0*/ x: kotlin.Any?): kotlin.Unit
Returns(WILDCARD) -> x != null