FIR checker: warn useless as and is

This commit is contained in:
Jinseong Jeon
2021-04-28 22:32:51 -07:00
committed by TeamCityServer
parent 19d939c36e
commit e2dc21da90
141 changed files with 417 additions and 543 deletions
@@ -37,4 +37,4 @@ fun case4() {
x checkType { check<Boolean>() }
}
class A
class A
@@ -1,83 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-435
* MAIN LINK: expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
* NUMBER: 1
* DESCRIPTION: Non-exhaustive when using subclasses of the sealed class.
* HELPERS: sealedClasses
*/
// TESTCASE NUMBER: 1
fun case_1(value_1: SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is SealedChild1 -> ""
is SealedChild2 -> ""
}
// TESTCASE NUMBER: 2
fun case_2(value_1: SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is SealedChild1, is SealedChild2 -> ""
}
// TESTCASE NUMBER: 3
fun case_3(value_1: SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is SealedMixedChild1 -> ""
is SealedMixedChild2 -> ""
SealedMixedChildObject1 -> ""
}
// TESTCASE NUMBER: 4
fun case_4(value_1: SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
SealedMixedChildObject1, is SealedMixedChild2, is SealedMixedChild1 -> ""
}
// TESTCASE NUMBER: 5
fun case_5(value_1: SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is SealedMixedChild1 -> ""
is SealedMixedChild2 -> ""
is SealedMixedChild3 -> ""
}
// TESTCASE NUMBER: 6
fun case_6(value_1: SealedClassMixed): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
// TESTCASE NUMBER: 7
fun case_7(value_1: SealedClassSingleWithObject): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
// TESTCASE NUMBER: 8
fun case_8(value_1: SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { }
// TESTCASE NUMBER: 9
fun case_9(value_1: Number): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
is Byte -> ""
is Double -> ""
is Float -> ""
is Int -> ""
is Long -> ""
is Short -> ""
}
/*
* TESTCASE NUMBER: 10
* DISCUSSION: maybe make exhaustive without else?
*/
fun case_10(value_1: Any): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
is Any -> ""
}
// TESTCASE NUMBER: 11
fun case_11(value_1: SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!> {
value_1 is SealedChild1 -> ""
value_1 is SealedChild2 -> ""
value_1 is SealedChild3 -> ""
}
// TESTCASE NUMBER: 12
fun case_12(value_1: SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is SealedMixedChild1 -> ""
is SealedMixedChild2 -> ""
is SealedMixedChild3 -> ""
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// SKIP_TXT
@@ -53,7 +53,7 @@ fun case_6(value_1: SealedClass?): String = when (value_1) {
// TESTCASE NUMBER: 7
fun case_7(value_1: SealedClassSingle): String = when (value_1) {
is SealedClassSingle -> ""
<!USELESS_IS_CHECK!>is SealedClassSingle<!> -> ""
else -> ""
}
@@ -11,7 +11,7 @@ fun case_1(value_1: SealedClass): Int = when (value_1) {
// TESTCASE NUMBER: 2
fun case_2(value_1: SealedClass): String = when (value_1) {
is SealedClass -> ""
<!USELESS_IS_CHECK!>is SealedClass<!> -> ""
}
// TESTCASE NUMBER: 3
@@ -73,7 +73,7 @@ fun case_6(value_1: Any) {
value_1 is String -> {}
value_1 is Number -> {}
value_1 is Float -> {}
value_1 is Any -> {}
<!USELESS_IS_CHECK!>value_1 is Any<!> -> {}
}
}
@@ -85,8 +85,8 @@ fun case_7(value_1: Any) {
when {
value_1 !is Number -> {}
value_1 is Float -> {}
value_1 is Number -> {}
value_1 is Any -> {}
<!USELESS_IS_CHECK!>value_1 is Number<!> -> {}
<!USELESS_IS_CHECK!>value_1 is Any<!> -> {}
}
}
@@ -29,7 +29,7 @@ fun case_3(value_1: Any?): String = when (value_1) {
// TESTCASE NUMBER: 4
fun case_4(value_1: Any): String = when (value_1) {
is Any? -> ""
<!USELESS_IS_CHECK!>is Any?<!> -> ""
else -> ""
}
@@ -70,7 +70,7 @@ interface A3
// TESTCASE NUMBER: 4
fun case4(x: C?) {
if (x is B4 && x is A4) {
if (x is B4 && <!USELESS_IS_CHECK!>x is A4<!>) {
x
<!DEBUG_INFO_EXPRESSION_TYPE("C? & C")!>x<!>
x.foo()
@@ -43,7 +43,7 @@ fun case_2(value: Any) {
// TESTCASE NUMBER: 3
fun case_3(value: String?) {
if (!value.isNullOrEmpty() is Boolean) {
if (<!USELESS_IS_CHECK!>!value.isNullOrEmpty() is Boolean<!>) {
value<!UNSAFE_CALL!>.<!>length
}
}
@@ -158,7 +158,7 @@ class case_10_class {
* ISSUES: KT-26747
*/
fun case_11(value_1: Any?, value_2: Any?, value_3: Any?) {
funWithReturnsAndInvertCondition(value_1 !is String || value_2 !is Number || value_3 !is Any?)
funWithReturnsAndInvertCondition(value_1 !is String || value_2 !is Number || <!USELESS_IS_CHECK!>value_3 !is Any?<!>)
println(value_1<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length)
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
}
@@ -6,7 +6,7 @@ import kotlin.contracts.*
// TESTCASE NUMBER: 1
fun <T : Number?> T.case_1() {
contract { returns() implies (this@case_1 is T) }
if (!(this@case_1 is T)) throw Exception()
if (!(<!USELESS_IS_CHECK!>this@case_1 is T<!>)) throw Exception()
}
// TESTCASE NUMBER: 2
@@ -43,7 +43,7 @@ class case_4 : ClassLevel3() {
fun <T>T.case_4_3_wrap() {
fun case_4_3_contract() {
contract { returns() implies (this@case_4_3_wrap is ClassLevel1) }
contract { returns() implies (<!USELESS_IS_CHECK!>this@case_4_3_wrap is ClassLevel1<!>) }
if (this@case_4_3_wrap !is ClassLevel1) throw Exception()
}
case_4_3_contract()
@@ -61,12 +61,12 @@ class case_5<T> : ClassLevel5() {
inner class case_5_1 {
fun <K : Number?>K.case_5_1_1() {
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 && <!UNRESOLVED_LABEL!>this@case_5_1<!> != null || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 && this@case_5_1_1 is Float)<!> }
if (!(this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || this@case_5 is ClassLevel1 && this is Float)) throw Exception()
if (!(this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> && this is Float)) throw Exception()
}
fun case_5_1_2() {
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5_1<!> == null)<!> }
if (!(this@case_5_1 !is ClassLevel1 || this@case_5 is ClassLevel1 || this@case_5_1 == null)) throw Exception()
if (!(this@case_5_1 !is ClassLevel1 || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> || this@case_5_1 == null)) throw Exception()
}
}
}
@@ -37,7 +37,7 @@ fun case_3() {
// TESTCASE NUMBER: 4
fun case_4(x: Char?) {
if (x != null || false is Boolean) {
if (x != null || <!USELESS_IS_CHECK!>false is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char?")!>x<!><!UNSAFE_CALL!>.<!>equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char?")!>x<!>.propT
@@ -55,7 +55,7 @@ fun case_4(x: Char?) {
fun case_5() {
val x: Unit? = null
if (x !== null is Boolean?) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>
if (x !== <!USELESS_IS_CHECK!>null is Boolean?<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>equals(null)
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propT
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>propAny
@@ -71,7 +71,7 @@ fun case_5() {
fun case_6(x: EmptyClass?) {
val y = true
if ((x != null && !y) is Boolean) {
if (<!USELESS_IS_CHECK!>(x != null && !y) is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyClass?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyClass?")!>x<!><!UNSAFE_CALL!>.<!>equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyClass?")!>x<!>.propT
@@ -111,7 +111,7 @@ fun case_8(x: TypealiasNullableString) {
fun case_9(x: TypealiasNullableString?) {
if (x === null === null) {
} else if (false is Boolean) {
} else if (<!USELESS_IS_CHECK!>false is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString?")!>x<!><!UNSAFE_CALL!>.<!>get(0)
}
@@ -121,7 +121,7 @@ fun case_9(x: TypealiasNullableString?) {
fun case_10() {
val a = Class()
if (a.prop_4 === null || true is Boolean) {
if (a.prop_4 === null || <!USELESS_IS_CHECK!>true is Boolean<!>) {
if (a.prop_4 != null !== null) {
a.prop_4
a.prop_4<!UNSAFE_CALL!>.<!>equals(null)
@@ -145,7 +145,7 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: TypealiasNullableStringIndir
} else {
if (y != null is Boolean == true) {
if ((nullableStringProperty == null) !is Boolean) {
if (<!USELESS_IS_CHECK!>(nullableStringProperty == null) !is Boolean<!>) {
if (t != null is Boolean) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect?")!>x<!>.equals(null)
@@ -165,8 +165,8 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: TypealiasNullableStringIndir
// TESTCASE NUMBER: 12
fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndirect) =
if ((x == null) !is Boolean === false) "1"
else if ((y === null !== null) is Boolean) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>
if (<!USELESS_IS_CHECK!>(x == null) !is Boolean<!> === false) "1"
else if (<!USELESS_IS_CHECK!>(y === null !== null) is Boolean<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.equals(null)
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.propT
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!><!UNSAFE_CALL!>.<!>propAny
@@ -198,19 +198,19 @@ class Case14 {
fun case_14() {
val a = Case14()
if (a.x != null !is Boolean !is Boolean) {
if (a.x != <!USELESS_IS_CHECK!>null !is Boolean !is Boolean<!>) {
if (a.x != null == true) {
if (a.x !== null == false) {
if (a.x != null == null) {
if (a.x != null !== null) {
if (a.x != null === true) {
if (a.x !== null === true !is Boolean == true) {
if (a.x !== null === <!USELESS_IS_CHECK!>true !is Boolean<!> == true) {
if (a.x != null !== false) {
if (a.x != null === false) {
if (a.x !== null === true) {
if ((a.x != null != true) !is Boolean) {
if (<!USELESS_IS_CHECK!>(a.x != null != true) !is Boolean<!>) {
if (a.x != null is Boolean) {
if (a.x != null is Boolean is Boolean) {
if (a.x != <!USELESS_IS_CHECK!>null is Boolean is Boolean<!>) {
if (a.x !== null is Boolean) {
if (a.x != null is Boolean) {
if ((a.x !== null !is Boolean) == false) {
@@ -236,7 +236,7 @@ fun case_14() {
// TESTCASE NUMBER: 15
fun case_15(x: EmptyObject) {
val t = if (x === null is Boolean is Boolean is Boolean) "" else {
val t = if (x === <!USELESS_IS_CHECK!><!USELESS_IS_CHECK!>null is Boolean is Boolean<!> is Boolean<!>) "" else {
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject")!>x<!>.propT
@@ -254,7 +254,7 @@ fun case_15(x: EmptyObject) {
fun case_16() {
val x: TypealiasNullableNothing = null
if (x != null !is Boolean !is Boolean !is Boolean !is Boolean !is Boolean) {
if (x != <!USELESS_IS_CHECK!><!USELESS_IS_CHECK!><!USELESS_IS_CHECK!><!USELESS_IS_CHECK!>null !is Boolean !is Boolean<!> !is Boolean<!> !is Boolean<!> !is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableNothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableNothing")!>x<!><!UNSAFE_CALL!>.<!>java
}
@@ -344,7 +344,7 @@ fun case_20(b: Boolean) {
// TESTCASE NUMBER: 21
fun case_21() {
if (EnumClassWithNullableProperty.B.prop_1 !== null is Boolean == true !is Boolean != true) {
if (EnumClassWithNullableProperty.B.prop_1 !== null is Boolean == <!USELESS_IS_CHECK!>true !is Boolean<!> != true) {
EnumClassWithNullableProperty.B.prop_1
EnumClassWithNullableProperty.B.prop_1<!UNSAFE_CALL!>.<!>equals(null)
EnumClassWithNullableProperty.B.prop_1.propT
@@ -458,7 +458,7 @@ fun case_26(a: ((Float) -> Int?)?, b: Float?) {
// TESTCASE NUMBER: 27
fun case_27() {
if (Object.prop_1 == null == true == true == true == true == true == true == true == true == true == true == true == true == true == true is Boolean)
if (Object.prop_1 == null == true == true == true == true == true == true == true == true == true == true == true == true == true == <!USELESS_IS_CHECK!>true is Boolean<!>)
else {
Object.prop_1
Object.prop_1<!UNSAFE_CALL!>.<!>equals(null)
@@ -12,7 +12,7 @@ fun case_1(x: Nothing?) {
// TESTCASE NUMBER: 2
fun case_2(x: Nothing) {
if (x is Unit) {
if (<!USELESS_IS_CHECK!>x is Unit<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>x<!>.inv()
}
@@ -28,7 +28,7 @@ fun case_3(x: Nothing?) {
// TESTCASE NUMBER: 4
fun case_4(x: Nothing) {
if (x !is EnumClass) else {
if (<!USELESS_IS_CHECK!>x !is EnumClass<!>) else {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>x<!>.<!UNRESOLVED_REFERENCE!>fun_1<!>()
}
@@ -36,7 +36,7 @@ fun case_4(x: Nothing) {
// TESTCASE NUMBER: 5
fun case_5(x: Nothing?) {
if (!(x !is Class.NestedClass?)) {
if (!(<!USELESS_IS_CHECK!>x !is Class.NestedClass?<!>)) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>?.<!UNRESOLVED_REFERENCE!>prop_4<!>
}
@@ -52,7 +52,7 @@ fun case_6(x: Nothing?) {
// TESTCASE NUMBER: 7
fun case_7(x: Nothing) {
if (!(x is DeepObject.A.B.C.D.E.F.G.J)) else {
if (!(<!USELESS_IS_CHECK!>x is DeepObject.A.B.C.D.E.F.G.J<!>)) else {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>x<!>.<!UNRESOLVED_REFERENCE!>prop_1<!>
}
@@ -60,7 +60,7 @@ fun case_7(x: Nothing) {
// TESTCASE NUMBER: 8
fun case_8(x: Nothing?) {
if (!(x is Int?)) else {
if (!(<!USELESS_IS_CHECK!>x is Int?<!>)) else {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>?.inv()
}
@@ -68,7 +68,7 @@ fun case_8(x: Nothing?) {
// TESTCASE NUMBER: 9
fun case_9(x: Nothing?) {
if (!!(x !is TypealiasNullableStringIndirect?)) else {
if (!!(<!USELESS_IS_CHECK!>x !is TypealiasNullableStringIndirect?<!>)) else {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>?.<!UNRESOLVED_REFERENCE!>length<!>
}
@@ -85,7 +85,7 @@ fun case_10(x: Nothing?) {
// TESTCASE NUMBER: 11
fun case_11(x: Nothing?) {
if (x is SealedMixedChildObject1?) {
if (<!USELESS_IS_CHECK!>x is SealedMixedChildObject1?<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>?.<!UNRESOLVED_REFERENCE!>prop_1<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>?.<!UNRESOLVED_REFERENCE!>prop_2<!>
@@ -4,7 +4,7 @@
// TESTCASE NUMBER: 1
fun case_1(x: Any?) {
if (x is Int is Boolean) {
if (<!USELESS_IS_CHECK!>x is Int is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>not<!>()
@@ -15,7 +15,7 @@ fun case_1(x: Any?) {
// TESTCASE NUMBER: 2
fun case_2(x: Any?) {
if (x is Int is Any? is Boolean) {
if (<!USELESS_IS_CHECK!><!USELESS_IS_CHECK!>x is Int is Any?<!> is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>not<!>()
@@ -86,7 +86,7 @@ fun case_8(x: Any?) {
// TESTCASE NUMBER: 9
fun case_9(x: Any?) {
if (x !is Int !is Any?) {
if (<!USELESS_IS_CHECK!>x !is Int !is Any?<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>propAny
@@ -132,7 +132,7 @@ inline fun <reified T, reified K, reified L>case_13(x: Any?) {
// TESTCASE NUMBER: 14
inline fun <reified T>case_14(x: Any?) {
if (!(x !is T is Boolean)) {
if (!(<!USELESS_IS_CHECK!>x !is T is Boolean<!>)) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>propAny
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>funAny()
@@ -141,7 +141,7 @@ inline fun <reified T>case_14(x: Any?) {
// TESTCASE NUMBER: 15
inline fun <reified T>case_15(x: Any?) {
if (!(x !is T) is Boolean) {
if (<!USELESS_IS_CHECK!>!(x !is T) is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>propAny
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>funAny()
@@ -12,7 +12,7 @@ fun case_1(x: Any?) {
// TESTCASE NUMBER: 2
fun case_2(x: Any) {
if (x is Number || x !is Number || x is Number) {
if (x is Number || x !is Number || <!USELESS_IS_CHECK!>x is Number<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>x<!>.<!UNRESOLVED_REFERENCE!>toByte<!>()
}
@@ -20,7 +20,7 @@ fun case_2(x: Any) {
// TESTCASE NUMBER: 3
fun case_3(x: Any?) {
if (x is Boolean || x !is Boolean is Boolean) {
if (x is Boolean || <!USELESS_IS_CHECK!>x !is Boolean is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>prop_1<!>
}
@@ -28,7 +28,7 @@ fun case_3(x: Any?) {
// TESTCASE NUMBER: 4
fun case_4(x: Any) {
if (x !is EnumClass || x !is EnumClass || x is EnumClass || x is EnumClass) {
if (x !is EnumClass || <!USELESS_IS_CHECK!>x !is EnumClass<!> || <!USELESS_IS_CHECK!>x is EnumClass<!> || <!USELESS_IS_CHECK!>x is EnumClass<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>x<!>.<!UNRESOLVED_REFERENCE!>fun_1<!>()
}
@@ -46,7 +46,7 @@ fun case_5(x: Any?) {
// TESTCASE NUMBER: 6
fun case_6(x: Any?) {
if (!(x is Object) || !!(x !is Object)) {
if (!(x is Object) || !!(<!USELESS_IS_CHECK!>x !is Object<!>)) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>prop_1<!>
}
@@ -54,7 +54,7 @@ fun case_6(x: Any?) {
// TESTCASE NUMBER: 7
fun case_7(x: Any) {
if (!(x is DeepObject.A.B.C.D.E.F.G.J) || !!!!!!(x is DeepObject.A.B.C.D.E.F.G.J)) {
if (!(x is DeepObject.A.B.C.D.E.F.G.J) || !!!!!!(<!USELESS_IS_CHECK!>x is DeepObject.A.B.C.D.E.F.G.J<!>)) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>x<!>.<!UNRESOLVED_REFERENCE!>prop_1<!>
}
@@ -5,7 +5,7 @@
// TESTCASE NUMBER: 1
fun case_1(x: Any?) {
if (x is Int) {
if (x !is Int) {
if (<!USELESS_IS_CHECK!>x !is Int<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Int")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Int")!>x<!>.inv()
}
@@ -35,7 +35,7 @@ fun case_3(x: Any?) {
// TESTCASE NUMBER: 4
fun case_4(x: Any) {
if (x !is EnumClass) else {
if (x !is EnumClass) {
if (<!USELESS_IS_CHECK!>x !is EnumClass<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & EnumClass")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & EnumClass")!>x<!>.fun_1()
}
@@ -45,7 +45,7 @@ fun case_4(x: Any) {
// TESTCASE NUMBER: 5
fun case_5(x: Any?) {
if (!(x !is Class.NestedClass?)) {
if (!!(x !is Class.NestedClass?)) {
if (!!(<!USELESS_IS_CHECK!>x !is Class.NestedClass?<!>)) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & Class.NestedClass?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & Class.NestedClass?")!>x<!>?.prop_4
}
@@ -106,7 +106,7 @@ fun case_10(x: Any?) {
// TESTCASE NUMBER: 11
fun case_11(x: Any?) {
if (x is SealedMixedChildObject1?) {
if (x is SealedMixedChildObject1?) {
if (<!USELESS_IS_CHECK!>x is SealedMixedChildObject1?<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & SealedMixedChildObject1?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & SealedMixedChildObject1?")!>x<!>?.prop_1
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & SealedMixedChildObject1?")!>x<!>?.prop_2
@@ -117,7 +117,7 @@ fun case_11(x: Any?) {
// TESTCASE NUMBER: 12
inline fun <reified T, reified K>case_12(x: Any?) {
if (x is T) {
if (x is T is K) {
if (<!USELESS_IS_CHECK!>x is T<!> is K) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T!!")!>x<!>
}
}
@@ -135,7 +135,7 @@ inline fun <reified T, reified K>case_13(x: Any?) {
// TESTCASE NUMBER: 14
inline fun <reified T, reified K>case_14(x: Any?) {
if (x is T) {
if (x !is T) {
if (<!USELESS_IS_CHECK!>x !is T<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T!!")!>x<!>
}
}
@@ -30,7 +30,7 @@ open class Case1<K : Number> {
// TESTCASE NUMBER: 2
inline fun <reified T : CharSequence>case_2(x: Any?) {
x as T
if (x !is T) {
if (<!USELESS_IS_CHECK!>x !is T<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>.get(0)
@@ -60,7 +60,7 @@ inline fun <reified T : CharSequence>case_4(x: Any?) {
// TESTCASE NUMBER: 5
inline fun <reified T : CharSequence>case_5(x: Any?) {
if (x as? T != null) {
if (x is T?) {
if (<!USELESS_IS_CHECK!>x is T?<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>.get(0)
@@ -30,7 +30,7 @@ open class Case1<K : Number> {
// TESTCASE NUMBER: 2
inline fun <reified T : CharSequence>case_2(x: Any?) {
x as T
if (x !is T) {
if (<!USELESS_IS_CHECK!>x !is T<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>.get(0)
@@ -60,7 +60,7 @@ inline fun <reified T : CharSequence>case_4(x: Any?) {
// TESTCASE NUMBER: 5
inline fun <reified T : CharSequence>case_5(x: Any?) {
if (x as? T != null) {
if (x is T?) {
if (<!USELESS_IS_CHECK!>x is T?<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>.get(0)
@@ -30,7 +30,7 @@ open class Case1<K : Number> {
// TESTCASE NUMBER: 2
inline fun <reified T : CharSequence>case_2(x: Any?) {
x as T
if (x !is T) {
if (<!USELESS_IS_CHECK!>x !is T<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>.get(0)
@@ -60,7 +60,7 @@ inline fun <reified T : CharSequence>case_4(x: Any?) {
// TESTCASE NUMBER: 5
inline fun <reified T : CharSequence>case_5(x: Any?) {
if (x as? T != null) {
if (x is T?) {
if (<!USELESS_IS_CHECK!>x is T?<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>.length
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>.get(0)
@@ -83,7 +83,7 @@ fun case_5(x: Class?) {
* ISSUES: KT-30376
*/
fun case_6(x: Class?) {
if ((x?.prop_8?.prop_8?.prop_8 as Class?)?.prop_8 == null == true) else {
if ((x?.prop_8?.prop_8?.prop_8 <!USELESS_CAST!>as Class?<!>)?.prop_8 == null == true) else {
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8.prop_8
@@ -73,7 +73,7 @@ fun case_5(a: Any?) {
if (
a is ClassLevel1
&& if (true) {b = a; false} else {b = a;true}
&& <!UNINITIALIZED_VARIABLE!>b<!> as ClassLevel2 is ClassLevel2
&& <!USELESS_IS_CHECK!><!UNINITIALIZED_VARIABLE!>b<!> as ClassLevel2 is ClassLevel2<!>
&& if (true) {c = <!UNINITIALIZED_VARIABLE!>b<!>;false} else {c = <!UNINITIALIZED_VARIABLE!>b<!>;false}
&& try {<!UNINITIALIZED_VARIABLE!>c<!> as ClassLevel3;true} finally {<!UNINITIALIZED_VARIABLE!>c<!> as ClassLevel3;false}
&& when (true) {else -> {d = <!UNINITIALIZED_VARIABLE!>c<!>;true}}
@@ -338,7 +338,7 @@ fun case_14(x: Any?) {
* ISSUES: KT-28362
*/
fun case_15(x: Any?) {
if (x !is ClassLevel2? || x !is ClassLevel1?) else {
if (x !is ClassLevel2? || <!USELESS_IS_CHECK!>x !is ClassLevel1?<!>) else {
if (x === null || x !is Interface1?) else {
if (x !is Interface2? || x !is Interface3?) {} else {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & ClassLevel2 & Interface1 & Interface2 & Interface3")!>x<!>
@@ -264,7 +264,7 @@ fun case_23(z: Any?) {
val y = z.run {
when (this) {
true -> this<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
0.0 -> this as Any
0.0 -> this <!USELESS_CAST!>as Any<!>
else -> this!!
}
}
@@ -277,7 +277,7 @@ fun case_24(z: Any?) {
val y = z.let {
when (it) {
true -> it<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
0.0 -> it as Any
0.0 -> it <!USELESS_CAST!>as Any<!>
else -> it!!
}
}
@@ -13,7 +13,7 @@ fun case_1() {
var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>.length
while (a is String) {
while (<!USELESS_IS_CHECK!>a is String<!>) {
b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>.length
@@ -119,7 +119,7 @@ fun case_6() {
var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>.length
if (a is String) {
if (<!USELESS_IS_CHECK!>a is String<!>) {
b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>b<!>.length
@@ -139,7 +139,7 @@ fun case_10() {
*/
fun case_11() {
var x: Any? = null
x as? Any ?: null!!
x <!USELESS_CAST!>as? Any<!> ?: null!!
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
@@ -187,7 +187,7 @@ fun case_14() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x is Any)
} while (<!USELESS_IS_CHECK!>x is Any<!>)
}
/*
@@ -201,6 +201,6 @@ fun case_15() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x <!UNSAFE_CALL!>.<!>equals(10)
} while (x is Any)
} while (<!USELESS_IS_CHECK!>x is Any<!>)
}
}
@@ -1386,7 +1386,7 @@ fun case_74(t: Any?) {
* ISSUES: KT-28362
*/
fun case_75(t: Any?, z: Nothing?) {
if (t !is ClassLevel2? || t !is ClassLevel1?) else {
if (t !is ClassLevel2? || <!USELESS_IS_CHECK!>t !is ClassLevel1?<!>) else {
if (t === ((((((z)))))) || t !is Interface1?) else {
if (t !is Interface2? || t !is Interface3?) {} else {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & ClassLevel2? & Interface1? & Interface2? & Interface3?")!>t<!><!UNSAFE_CALL!>.<!>itest2()
@@ -78,7 +78,7 @@ fun case_5(x: Pair<*, *>?) {
fun case_6(x: Any?) {
when (x) {
is Nothing? -> return
is Any? -> {
<!USELESS_IS_CHECK!>is Any?<!> -> {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>equals(10)
}