Add 'mute' concept: move tests with unexpected behaviour to the corresponding folder
This commit is contained in:
+58
@@ -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)
|
||||
})
|
||||
}
|
||||
+11
@@ -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
|
||||
+4
-4
@@ -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
|
||||
*/
|
||||
+54
@@ -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
|
||||
}
|
||||
+7
@@ -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
|
||||
+31
@@ -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
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun case_1(): kotlin.Boolean
|
||||
public fun case_2(): kotlin.Boolean
|
||||
public fun case_3(): kotlin.Boolean
|
||||
+5
-14
@@ -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
|
||||
}
|
||||
|
||||
+6
-40
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
+6
-9
@@ -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)
|
||||
|
||||
|
||||
+38
-8
@@ -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
|
||||
}
|
||||
|
||||
+5
-6
@@ -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
|
||||
|
||||
+10
-38
@@ -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
|
||||
}
|
||||
+5
-5
@@ -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
|
||||
|
||||
+32
@@ -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()
|
||||
}
|
||||
+9
@@ -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)
|
||||
+8
-14
@@ -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()
|
||||
}
|
||||
|
||||
+2
-5
@@ -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)
|
||||
|
||||
Vendored
+2
-8
@@ -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() {
|
||||
|
||||
Vendored
+27
@@ -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()
|
||||
}
|
||||
compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/3.txt
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun case_1(): kotlin.Unit
|
||||
public fun funWithContractExactlyOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
CallsInPlace(block, EXACTLY_ONCE)
|
||||
Vendored
+21
-11
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
|
||||
compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/1.txt
Vendored
+8
-3
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user