Deprecate simplification of complex boolean constant expressions in whens and loops
^KT-39883 In Progress
This commit is contained in:
committed by
teamcityserver
parent
8a2e0cedf9
commit
05883afc0a
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: -ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun t1() : Int{
|
||||
|
||||
Vendored
+4
-3
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: -ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun t1() : Int{
|
||||
@@ -68,12 +69,12 @@ fun t5() : Int {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
while (<!UNREACHABLE_CODE!>1 > 2<!>)
|
||||
while (<!NON_TRIVIAL_BOOLEAN_CONSTANT, UNREACHABLE_CODE!>1 > 2<!>)
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
fun t6() : Int {
|
||||
while (1 > 2) {
|
||||
while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>1 > 2<!>) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
@@ -81,7 +82,7 @@ fun t6() : Int {
|
||||
}
|
||||
|
||||
fun t6break() : Int {
|
||||
while (1 > 2) {
|
||||
while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>1 > 2<!>) {
|
||||
break
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: -ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
fun unreachable() {}
|
||||
|
||||
fun a() {
|
||||
@@ -52,4 +53,4 @@ fun h(): Int {
|
||||
while (true) {
|
||||
if (true) return 12
|
||||
}
|
||||
} // should work
|
||||
} // should work
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: -ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
fun unreachable() {}
|
||||
|
||||
fun a() {
|
||||
@@ -13,11 +14,11 @@ fun b() {
|
||||
}
|
||||
|
||||
fun c() {
|
||||
do {} while (1 == 1)
|
||||
do {} while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>1 == 1<!>)
|
||||
}
|
||||
|
||||
fun d() {
|
||||
while (2 == 2) {}
|
||||
while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>2 == 2<!>) {}
|
||||
}
|
||||
|
||||
fun use(arg: Any) = arg
|
||||
@@ -52,4 +53,4 @@ fun h(): Int {
|
||||
while (true) {
|
||||
if (true) return 12
|
||||
}
|
||||
} // should work
|
||||
} // should work
|
||||
|
||||
Vendored
+72
@@ -0,0 +1,72 @@
|
||||
// LANGUAGE: +ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
// DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun test_1() {
|
||||
while (true) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
while (true || false) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
while (1 == 1) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_4() {
|
||||
while (false) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
while (false && true) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_6() {
|
||||
do {
|
||||
|
||||
} while (true)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_7() {
|
||||
do {
|
||||
|
||||
} while (true || false)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_8() {
|
||||
do {
|
||||
|
||||
} while (1 == 1)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_9() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (false)
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_10() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (false && true)
|
||||
val y = 2
|
||||
}
|
||||
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
// LANGUAGE: +ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
// DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun test_1() {
|
||||
while (true) {
|
||||
|
||||
}
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
while (true || false) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
while (1 == 1) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_4() {
|
||||
while (false) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
while (false && true) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_6() {
|
||||
do {
|
||||
|
||||
} while (true)
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_7() {
|
||||
do {
|
||||
|
||||
} while (true || false)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_8() {
|
||||
do {
|
||||
|
||||
} while (1 == 1)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_9() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (false)
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_10() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (false && true)
|
||||
val y = 2
|
||||
}
|
||||
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun test_1(): kotlin.Unit
|
||||
public fun test_10(): kotlin.Unit
|
||||
public fun test_2(): kotlin.Unit
|
||||
public fun test_3(): kotlin.Unit
|
||||
public fun test_4(): kotlin.Unit
|
||||
public fun test_5(): kotlin.Unit
|
||||
public fun test_6(): kotlin.Unit
|
||||
public fun test_7(): kotlin.Unit
|
||||
public fun test_8(): kotlin.Unit
|
||||
public fun test_9(): kotlin.Unit
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// LANGUAGE: -ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
// DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun test_1() {
|
||||
while (true) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
while (true || false) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
while (1 == 1) {
|
||||
|
||||
}
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_4() {
|
||||
while (false) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
while (false && true) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_6() {
|
||||
do {
|
||||
|
||||
} while (true)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_7() {
|
||||
do {
|
||||
|
||||
} while (true || false)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_8() {
|
||||
do {
|
||||
|
||||
} while (1 == 1)
|
||||
val x = 1
|
||||
}
|
||||
|
||||
fun test_9() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (false)
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_10() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (false && true)
|
||||
val y = 2
|
||||
}
|
||||
Vendored
+72
@@ -0,0 +1,72 @@
|
||||
// LANGUAGE: -ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
// DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun test_1() {
|
||||
while (true) {
|
||||
|
||||
}
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>true || false<!>) {
|
||||
|
||||
}
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>1 == 1<!>) {
|
||||
|
||||
}
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_4() {
|
||||
while (false) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>false && true<!>) {
|
||||
val x = 1
|
||||
}
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_6() {
|
||||
do {
|
||||
|
||||
} while (true)
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_7() {
|
||||
do {
|
||||
|
||||
} while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>true || false<!>)
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_8() {
|
||||
do {
|
||||
|
||||
} while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>1 == 1<!>)
|
||||
<!UNREACHABLE_CODE!>val x = 1<!>
|
||||
}
|
||||
|
||||
fun test_9() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (false)
|
||||
val y = 2
|
||||
}
|
||||
|
||||
fun test_10() {
|
||||
do {
|
||||
val x = 1
|
||||
} while (<!NON_TRIVIAL_BOOLEAN_CONSTANT!>false && true<!>)
|
||||
val y = 2
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun test_1(): kotlin.Unit
|
||||
public fun test_10(): kotlin.Unit
|
||||
public fun test_2(): kotlin.Unit
|
||||
public fun test_3(): kotlin.Unit
|
||||
public fun test_4(): kotlin.Unit
|
||||
public fun test_5(): kotlin.Unit
|
||||
public fun test_6(): kotlin.Unit
|
||||
public fun test_7(): kotlin.Unit
|
||||
public fun test_8(): kotlin.Unit
|
||||
public fun test_9(): kotlin.Unit
|
||||
|
||||
Reference in New Issue
Block a user