// !DIAGNOSTICS: -UNUSED_EXPRESSION // SKIP_TXT // WITH_EXTENDED_CHECKERS /* * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) * * SECTIONS: dfa * NUMBER: 7 * DESCRIPTION: Raw data flow analysis test * UNEXPECTED BEHAVIOUR * HELPERS: classes, enumClasses, objects, typealiases, properties, functions */ // FILE: other_package.kt package orherpackage // TESTCASE NUMBER: 13 class EmptyClass13 {} // TESTCASE NUMBER: 14 typealias TypealiasString14 = String? // FILE: main.kt import orherpackage.* // TESTCASE NUMBER: 1 fun case_1(x: Any?) { if (x != null || x != null || x != null || x != null || x != null || x != null || x != null) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } /* * TESTCASE NUMBER: 2 * UNEXPECTED BEHAVIOUR * ISSUES: KT-28159 */ fun case_2(x: Nothing?) { if (x !== null && x !== null) { x } } // TESTCASE NUMBER: 3 fun case_3() { if (Object.prop_1 == null && Object.prop_1 == null) else { Object.prop_1 Object.prop_1.equals(null) Object.prop_1.propT Object.prop_1.propAny Object.prop_1.propNullableT Object.prop_1.propNullableAny Object.prop_1.funT() Object.prop_1.funAny() Object.prop_1.funNullableT() Object.prop_1.funNullableAny() } } // TESTCASE NUMBER: 4 fun case_4(x: Char?) { if (x != null && true || x != null) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } // TESTCASE NUMBER: 5 fun case_5() { val x: Unit? = null if (x !== null || x !== null && x !== null || x !== null && x !== null) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } // TESTCASE NUMBER: 6 fun case_6(x: Class?) { val y = true if (((false || x != null || false) && !y) || x != null) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } // TESTCASE NUMBER: 7 fun case_7() { val x: EmptyObject? = null if (x != null || x != null || x != null) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } // TESTCASE NUMBER: 8 fun case_8(x: TypealiasString) { if (x !== null && x != null) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } // TESTCASE NUMBER: 9 fun case_9(x: TypealiasNullableString?) { if (x === null && x === null || x === null) { } else if (x === null || x === null) { } else if (false) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } // TESTCASE NUMBER: 10 fun case_10() { val a = Class() if (a.prop_4 === null || a.prop_4 === null || true) { if (a.prop_4 != null) { a.prop_4 a.prop_4.equals(null) a.prop_4.propT a.prop_4.propAny a.prop_4.propNullableT a.prop_4.propNullableAny a.prop_4.funT() a.prop_4.funAny() a.prop_4.funNullableT() a.prop_4.funNullableAny() } } } // TESTCASE NUMBER: 11 fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) { val t: TypealiasNullableString = null if (x == null) { } else { if (x != null) { if (y != null || y != null) { if (stringProperty == null && nullableNothingProperty == null) { if (t != null || t != null) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } } } } } // TESTCASE NUMBER: 12 fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = if (x == null) "1" else if (y === null || y === null) { x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() x } else "-1" // TESTCASE NUMBER: 13 fun case_13(x: orherpackage.EmptyClass13?, y: Nothing?) = if (x == null || x === y) { throw Exception() } else { x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() x } // TESTCASE NUMBER: 14 fun case_14() { val a = Class() if (a.prop_6 != a.prop_7) { a.prop_6 a.prop_6.equals(null) a.prop_6.propT a.prop_6.propAny a.prop_6.propNullableT a.prop_6.propNullableAny a.prop_6.funT() a.prop_6.funAny() a.prop_6.funNullableT() a.prop_6.funNullableAny() } } // TESTCASE NUMBER: 15 fun case_15(x: TypealiasString?) { var y = null val t = if (x === null || x == y && x === y) "" else { x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() x } } // TESTCASE NUMBER: 16 fun case_16() { val x: TypealiasNothing? = null val y: Nothing? = null if (x != null || x !== null || x != y) { x x.hashCode() } } // TESTCASE NUMBER: 17 val case_17 = if (nullableIntProperty == null || nullableNothingProperty === nullableIntProperty) 0 else { nullableIntProperty.equals(null) nullableIntProperty.propT nullableIntProperty.propAny nullableIntProperty.propNullableT nullableIntProperty.propNullableAny nullableIntProperty.funT() nullableIntProperty.funAny() nullableIntProperty.funNullableT() nullableIntProperty.funNullableAny() nullableIntProperty } /* * TESTCASE NUMBER: 18 * UNEXPECTED BEHAVIOUR * ISSUES: KT-28328 */ fun case_18(a: DeepObject.A.B.C.D.E.F.G.J?, b: Nothing?) { if (a != null || b !== a || false) { a a.equals(null) a.propT a.propAny a.propNullableT a.propNullableAny a.funT() a.funAny() a.funNullableT() a.funNullableAny() } } // TESTCASE NUMBER: 19 fun case_19(b: Boolean) { val a = if (b) { object { var y = null val B19 = if (b) { object { val C19 = if (b) { object { val D19 = if (b) { object { val x: Number? = 10 } } else null } } else null } } else null } } else null if (a != null && a.B19 != a.y && a.B19.C19 != a.y && a.B19.C19.D19 != a.y && a.B19.C19.D19.x != a.y) { a.B19.C19.D19.x a.B19.C19.D19.x.equals(null) a.B19.C19.D19.x.propT a.B19.C19.D19.x.propAny a.B19.C19.D19.x.propNullableT a.B19.C19.D19.x.propNullableAny a.B19.C19.D19.x.funT() a.B19.C19.D19.x.funAny() a.B19.C19.D19.x.funNullableT() a.B19.C19.D19.x.funNullableAny() } } // TESTCASE NUMBER: 20 fun case_20(b: Boolean) { val a = object { val y = null val B19 = object { val C19 = object { val D19 = if (b) { object {} } else null } } } if (a.B19.C19.D19 !== null || a.y != a.B19.C19.D19) { `.B19.``.C19.``.D19.`` & case_20.``.B19.``.C19.``.D19.``?")!>a.B19.C19.D19 `.B19.``.C19.``.D19.``"), DEBUG_INFO_SMARTCAST!>a.B19.C19.D19.equals(null) `.B19.``.C19.``.D19.``"), DEBUG_INFO_SMARTCAST!>a.B19.C19.D19.propT `.B19.``.C19.``.D19.``"), DEBUG_INFO_SMARTCAST!>a.B19.C19.D19.propAny `.B19.``.C19.``.D19.`` & case_20.``.B19.``.C19.``.D19.``?")!>a.B19.C19.D19.propNullableT `.B19.``.C19.``.D19.`` & case_20.``.B19.``.C19.``.D19.``?")!>a.B19.C19.D19.propNullableAny `.B19.``.C19.``.D19.``"), DEBUG_INFO_SMARTCAST!>a.B19.C19.D19.funT() `.B19.``.C19.``.D19.``"), DEBUG_INFO_SMARTCAST!>a.B19.C19.D19.funAny() `.B19.``.C19.``.D19.`` & case_20.``.B19.``.C19.``.D19.``?")!>a.B19.C19.D19.funNullableT() `.B19.``.C19.``.D19.`` & case_20.``.B19.``.C19.``.D19.``?")!>a.B19.C19.D19.funNullableAny() } } // TESTCASE NUMBER: 21 fun case_21() { val y = null if (EnumClassWithNullableProperty.A.prop_1 !== null && y != EnumClassWithNullableProperty.A.prop_1) { EnumClassWithNullableProperty.A.prop_1 EnumClassWithNullableProperty.A.prop_1.equals(null) EnumClassWithNullableProperty.A.prop_1.propT EnumClassWithNullableProperty.A.prop_1.propAny EnumClassWithNullableProperty.A.prop_1.propNullableT EnumClassWithNullableProperty.A.prop_1.propNullableAny EnumClassWithNullableProperty.A.prop_1.funT() EnumClassWithNullableProperty.A.prop_1.funAny() EnumClassWithNullableProperty.A.prop_1.funNullableT() EnumClassWithNullableProperty.A.prop_1.funNullableAny() } } // TESTCASE NUMBER: 22 fun case_22(a: (() -> Unit)?) { var y = null if (a != null || y != a) { kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a() kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.equals(null) kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.propT kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.propAny kotlin.Unit)? & () -> kotlin.Unit")!>a.propNullableT kotlin.Unit)? & () -> kotlin.Unit")!>a.propNullableAny kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.funT() kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.funAny() kotlin.Unit)? & () -> kotlin.Unit")!>a.funNullableT() kotlin.Unit)? & () -> kotlin.Unit")!>a.funNullableAny() } } // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?, c: Nothing?) { if (a != null && b !== null || a != c && b !== c) { val x = kotlin.Int?)? & (kotlin.Float) -> kotlin.Int?"), DEBUG_INFO_SMARTCAST!>a(b) if (x != null || c !== x) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } } // TESTCASE NUMBER: 24 fun case_24(a: ((() -> Unit) -> Unit)?, b: (() -> Unit)?) = if (a !== null && b !== null || implicitNullableNothingProperty != a && nullableNothingProperty !== b) { kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a( kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>b) kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.equals(null) kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.propT kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.propAny kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit")!>a.propNullableT kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit")!>a.propNullableAny kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.funT() kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>a.funAny() kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit")!>a.funNullableT() kotlin.Unit) -> kotlin.Unit)? & (() -> kotlin.Unit) -> kotlin.Unit")!>a.funNullableAny() kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>b.equals(null) kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>b.propT kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>b.propAny kotlin.Unit)? & () -> kotlin.Unit")!>b.propNullableT kotlin.Unit)? & () -> kotlin.Unit")!>b.propNullableAny kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>b.funT() kotlin.Unit)? & () -> kotlin.Unit"), DEBUG_INFO_SMARTCAST!>b.funAny() kotlin.Unit)? & () -> kotlin.Unit")!>b.funNullableT() kotlin.Unit)? & () -> kotlin.Unit")!>b.funNullableAny() } else null // TESTCASE NUMBER: 25 fun case_25(b: Boolean) { val x = { if (b) object { val a = 10 val b = null } else null } val y = if (b) x else null if (y !== null || x()!!.b != y) { if (x()!!.b != y) { val z = `.``?")!> case_25.``.``?)? & () -> case_25.``.``?"), DEBUG_INFO_SMARTCAST!>y() if (z != null) { `.`` & case_25.``.``?"), DEBUG_INFO_SMARTCAST!>z.a `.`` & case_25.``.``?"), DEBUG_INFO_SMARTCAST!>z.equals(null) `.`` & case_25.``.``?"), DEBUG_INFO_SMARTCAST!>z.propT `.`` & case_25.``.``?"), DEBUG_INFO_SMARTCAST!>z.propAny `.`` & case_25.``.``?")!>z.propNullableT `.`` & case_25.``.``?")!>z.propNullableAny `.`` & case_25.``.``?"), DEBUG_INFO_SMARTCAST!>z.funT() `.`` & case_25.``.``?"), DEBUG_INFO_SMARTCAST!>z.funAny() `.`` & case_25.``.``?")!>z.funNullableT() `.`` & case_25.``.``?")!>z.funNullableAny() } } } } // TESTCASE NUMBER: 26 fun case_26(a: ((Float) -> Int?)?, b: Float?) { var c: Nothing? = null if (a != null == true && b != null == true || c != a == true && b != c == true) { val x = kotlin.Int?)? & (kotlin.Float) -> kotlin.Int?"), DEBUG_INFO_SMARTCAST!>a(b) if (x != null == true) { x x.equals(null) x.propT x.propAny x.propNullableT x.propNullableAny x.funT() x.funAny() x.funNullableT() x.funNullableAny() } } } // TESTCASE NUMBER: 27 fun case_27(y: Nothing?) { if (Object.prop_1 == null == true == true == true == true == true == true == true == true == true == true == true == true == true == true || y == Object.prop_1 == true == true == true == false == false) else { Object.prop_1 Object.prop_1.equals(null) Object.prop_1.propT Object.prop_1.propAny Object.prop_1.propNullableT Object.prop_1.propNullableAny Object.prop_1.funT() Object.prop_1.funAny() Object.prop_1.funNullableT() Object.prop_1.funNullableAny() } } //TESTCASE NUMBER: 28 fun case_28(a: DeepObject.A.B.C.D.E.F.G.J?) = if (a != null == true == false == false == false == true == false == true == false == false == true == true && a.x !== nullableNothingProperty) { a.x a.equals(null) a.propT a.propAny a.propNullableT a.propNullableAny a.funT() a.funAny() a.funNullableT() a.funNullableAny() } else -1 // TESTCASE NUMBER: 29 fun case_29(a: Int?, b: Nothing?, c: Int = if (a === b) 0 else a) { a b } // TESTCASE NUMBER: 30 fun case_30(a: Int?, b: Nothing?, c: Int = if (a === b || a == null) 0 else a) { a b }