[FIR] Add FINAL_UPPER_BOUND checker
This commit is contained in:
Vendored
+5
-5
@@ -110,15 +110,15 @@ fun <T : Number> T.case_19_4(): Boolean? {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 20
|
||||
fun <T : String> T?.case_20_1(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_20_1(): Boolean {
|
||||
contract { returns(true) implies (this@case_20_1 != null) }
|
||||
return this@case_20_1 != null
|
||||
}
|
||||
fun <T : String> T?.case_20_2(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_20_2(): Boolean {
|
||||
contract { returns(true) implies (this@case_20_2 == null) }
|
||||
return this@case_20_2 == null
|
||||
}
|
||||
fun <T : String> T?.case_20_3(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_20_3(): Boolean {
|
||||
contract { returns(false) implies (this@case_20_3 != null) }
|
||||
return !(this@case_20_3 != null)
|
||||
}
|
||||
@@ -132,11 +132,11 @@ fun <T : String?> T.case_21_2(): Boolean {
|
||||
contract { returns(true) implies (this@case_21_2 == null) }
|
||||
return this@case_21_2 == null
|
||||
}
|
||||
fun <T : String> T?.case_21_5(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_5(): Boolean? {
|
||||
contract { returnsNotNull() implies (this@case_21_5 != null) }
|
||||
return if (this@case_21_5 != null) true else null
|
||||
}
|
||||
fun <T : String> T?.case_21_7(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_21_7(): Boolean? {
|
||||
contract { returns(null) implies (this@case_21_7 != null) }
|
||||
return if (this@case_21_7 != null) null else true
|
||||
}
|
||||
|
||||
Vendored
+6
-6
@@ -20,11 +20,11 @@ fun <T : Number> T.case_2() {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun <T : String> T?.case_3_1() {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_3_1() {
|
||||
contract { returns() implies (this@case_3_1 == null) }
|
||||
if (!(this@case_3_1 == null)) throw Exception()
|
||||
}
|
||||
fun <T : String> T?.case_3_2() {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_3_2() {
|
||||
contract { returns() implies (this@case_3_2 != null) }
|
||||
if (!(this@case_3_2 != null)) throw Exception()
|
||||
}
|
||||
@@ -76,19 +76,19 @@ fun <T : Number> T.case_6_4(): Boolean? {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 7
|
||||
fun <T : String> T?.case_7_1(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_1(): Boolean {
|
||||
contract { returns(true) implies (this@case_7_1 == null) }
|
||||
return this@case_7_1 == null
|
||||
}
|
||||
fun <T : String> T?.case_7_2(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_2(): Boolean {
|
||||
contract { returns(false) implies (this@case_7_2 != null) }
|
||||
return !(this@case_7_2 != null)
|
||||
}
|
||||
fun <T : String> T?.case_7_3(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_3(): Boolean? {
|
||||
contract { returnsNotNull() implies (this@case_7_3 != null) }
|
||||
return if (this@case_7_3 != null) true else null
|
||||
}
|
||||
fun <T : String> T?.case_7_4(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_4(): Boolean? {
|
||||
contract { returns(null) implies (this@case_7_4 != null) }
|
||||
return if (this@case_7_4 != null) null else true
|
||||
}
|
||||
|
||||
Vendored
+13
-13
@@ -20,11 +20,11 @@ fun <T : Number> T.case_2() {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun <T : String> T?.case_3_1() {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_3_1() {
|
||||
contract { returns() implies (this@case_3_1 != null) }
|
||||
if (!(this@case_3_1 != null)) throw Exception()
|
||||
}
|
||||
fun <T : String> T?.case_3_2() {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_3_2() {
|
||||
contract { returns() implies (this@case_3_2 == null) }
|
||||
if (!(this@case_3_2 == null)) throw Exception()
|
||||
}
|
||||
@@ -76,47 +76,47 @@ fun <T : Number> T.case_6_4(): Boolean? {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 7
|
||||
fun <T : String> T?.case_7_1(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_1(): Boolean {
|
||||
contract { returns(true) implies (this@case_7_1 != null) }
|
||||
return this@case_7_1 != null
|
||||
}
|
||||
fun <T : String> T?.case_7_2(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_2(): Boolean {
|
||||
contract { returns(true) implies (this@case_7_2 == null) }
|
||||
return this@case_7_2 == null
|
||||
}
|
||||
fun <T : String> T?.case_7_3(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_3(): Boolean? {
|
||||
contract { returnsNotNull() implies (this@case_7_3 == null) }
|
||||
return if (this@case_7_3 == null) true else null
|
||||
}
|
||||
fun <T : String> T?.case_7_4(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_4(): Boolean? {
|
||||
contract { returns(null) implies (this@case_7_4 == null) }
|
||||
return if (this@case_7_4 == null) null else true
|
||||
}
|
||||
fun <T : String> T?.case_7_5(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_5(): Boolean {
|
||||
contract { returns(false) implies (this@case_7_5 == null) }
|
||||
return !(this@case_7_5 == null)
|
||||
}
|
||||
fun <T : String> T?.case_7_6(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_6(): Boolean? {
|
||||
contract { returnsNotNull() implies (this@case_7_6 != null) }
|
||||
return if (this@case_7_6 != null) true else null
|
||||
}
|
||||
fun <T : String> T?.case_7_7(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_7(): Boolean? {
|
||||
contract { returns(null) implies (this@case_7_7 != null) }
|
||||
return if (this@case_7_7 != null) null else true
|
||||
}
|
||||
fun <T : String> T?.case_7_8(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_8(): Boolean {
|
||||
contract { returns(false) implies (this@case_7_8 != null) }
|
||||
return !(this@case_7_8 != null)
|
||||
}
|
||||
fun <T : String> T?.case_7_9(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_9(): Boolean {
|
||||
contract { returns(false) implies (this@case_7_9 == null) }
|
||||
return !(this@case_7_9 == null)
|
||||
}
|
||||
fun <T : String> T?.case_7_10(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_10(): Boolean? {
|
||||
contract { returnsNotNull() implies (this@case_7_10 == null) }
|
||||
return if (this@case_7_10 == null) true else null
|
||||
}
|
||||
fun <T : String> T?.case_7_11(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_7_11(): Boolean? {
|
||||
contract { returns(null) implies (this@case_7_11 == null) }
|
||||
return if (this@case_7_11 == null) null else true
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
import kotlin.contracts.*
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun <T : Boolean>T.case_1(): Boolean? {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Boolean<!>>T.case_1(): Boolean? {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(null) implies (!this@case_1)<!> }
|
||||
return if (!this) null else true
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ fun Boolean?.case_1(): Boolean {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
fun <T : Boolean>T?.case_2(): Boolean {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Boolean<!>>T?.case_2(): Boolean {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (this@case_2 != null && this@case_2 !is Nothing && this@case_2)<!> }
|
||||
return this != null && this !is Nothing && this
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ fun <T : Number?> T.case_1() {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
fun <T : Number, K : String> T?.case_2(value_1: K?) {
|
||||
fun <T : Number, K : <!FINAL_UPPER_BOUND!>String<!>> T?.case_2(value_1: K?) {
|
||||
contract { returns() implies (this@case_2 is T && value_1 is K) }
|
||||
if (!(this@case_2 is T && value_1 is K)) throw Exception()
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class case_4 : ClassLevel3() {
|
||||
return this == null
|
||||
}
|
||||
|
||||
fun <T : Boolean>T.case_4_2() {
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Boolean<!>>T.case_4_2() {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (!this@case_4_2)<!> }
|
||||
if (this) throw Exception()
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ inline fun <reified T>case_3(x: Any?) {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
inline fun <reified T : Boolean>case_4(x: Any?) {
|
||||
inline fun <reified T : <!FINAL_UPPER_BOUND!>Boolean<!>>case_4(x: Any?) {
|
||||
if (x is Int is T == null) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
|
||||
|
||||
@@ -97,8 +97,8 @@ fun case_9() {
|
||||
* UNEXPECTED BEHAVIOUR
|
||||
* ISSUES: KT-22175
|
||||
*/
|
||||
fun <T : String> T?.case_10() = this
|
||||
fun <T : Int> T?.case_10() = this
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_10() = this
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Int<!>> T?.case_10() = this
|
||||
fun case_10() {
|
||||
var x: Int? = 10
|
||||
x = null
|
||||
@@ -106,7 +106,7 @@ fun case_10() {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 11
|
||||
fun <T : String> T?.case_11() = this
|
||||
fun <T : <!FINAL_UPPER_BOUND!>String<!>> T?.case_11() = this
|
||||
fun case_11() {
|
||||
var x: Int? = 10
|
||||
x = null
|
||||
|
||||
Reference in New Issue
Block a user