// !DIAGNOSTICS: -UNUSED_EXPRESSION // SKIP_TXT /* * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) * * SECTIONS: dfa * NUMBER: 11 * DESCRIPTION: Raw data flow analysis test * HELPERS: classes, functions, interfaces, properties */ // TESTCASE NUMBER: 1 fun , C: Out> case_1(a: C, b: B) = select(a.x, b.x) fun case_1() { val x = case_1(Out(10), Inv(0.1)) if (x != null) { & Number} & {Comparable<*> & Number}?")!>x & Number} & {Comparable<*> & Number}?")!>x.equals(null) & Number} & {Comparable<*> & Number}?")!>x.propT & Number} & {Comparable<*> & Number}?")!>x.propAny & Number} & {Comparable<*> & Number}?")!>x.propNullableT & Number} & {Comparable<*> & Number}?")!>x.propNullableAny & Number} & {Comparable<*> & Number}?")!>x.funT() & Number} & {Comparable<*> & Number}?")!>x.funAny() & Number} & {Comparable<*> & Number}?")!>x.funNullableT() & Number} & {Comparable<*> & Number}?")!>x.funNullableAny() } } // TESTCASE NUMBER: 2 fun , C: Out> case_2(a: C, b: B) = select(a.x, b.x) fun case_2(y: Int) { val x = case_2(Out(y), Inv(0.1)) if (x != null) { & Number} & {Comparable<*> & Number}?")!>x & Number} & {Comparable<*> & Number}?")!>x.equals(null) & Number} & {Comparable<*> & Number}?")!>x.propT & Number} & {Comparable<*> & Number}?")!>x.propAny & Number} & {Comparable<*> & Number}?")!>x.propNullableT & Number} & {Comparable<*> & Number}?")!>x.propNullableAny & Number} & {Comparable<*> & Number}?")!>x.funT() & Number} & {Comparable<*> & Number}?")!>x.funAny() & Number} & {Comparable<*> & Number}?")!>x.funNullableT() & Number} & {Comparable<*> & Number}?")!>x.funNullableAny() } } /* * TESTCASE NUMBER: 3 * ISSUES: KT-28670 */ fun case_3(a: Int?, b: Float?, c: Double?, d: Boolean?) { when (d) { true -> a false -> b null -> c }.apply { ? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this if (this != null) { & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.equals(null) & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.propT & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.propAny & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.propNullableT & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.propNullableAny & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.funT() & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.funAny() & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.funNullableT() & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.funNullableAny() } }.let { ? & Number?}")!>it if (it != null) { & Number} & {Comparable? & Number?}")!>it & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.equals(null) & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.propT & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.propAny & Number} & {Comparable? & Number?}")!>it.propNullableT & Number} & {Comparable? & Number?}")!>it.propNullableAny & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.funT() & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.funAny() & Number} & {Comparable? & Number?}")!>it.funNullableT() & Number} & {Comparable? & Number?}")!>it.funNullableAny() } } } /* * TESTCASE NUMBER: 4 * ISSUES: KT-28670 */ fun case_4(a: Interface1?, b: Interface2?, c: Boolean) { a as Interface2? b as Interface1? val x = when (c) { true -> a false -> b } x.apply { this if (this != null) { this this.equals(null) this.propT this.propAny this.propNullableT this.propNullableAny this.funT() this.funAny() this.funNullableT() this.funNullableAny() } } x.let { it if (it != null) { it it.equals(null) it.propT it.propAny it.propNullableT it.propNullableAny it.funT() it.funAny() it.funNullableT() it.funNullableAny() } } } /* * TESTCASE NUMBER: 5 * ISSUES: KT-28670 */ fun case_5(a: Interface1?, b: Interface2?, d: Boolean) { a as Interface2? b as Interface1 val x = when (d) { true -> a false -> b } x.apply { if (this != null) { this this.equals(null) this.propT this.propAny this.propNullableT this.propNullableAny this.funT() this.funAny() this.funNullableT() this.funNullableAny() } } x.let { if (it != null) { it it.equals(null) it.propT it.propAny it.propNullableT it.propNullableAny it.funT() it.funAny() it.funNullableT() it.funNullableAny() } } } /* * TESTCASE NUMBER: 6 * ISSUES: KT-28670 */ fun case_6(a: Interface1?, b: Interface2, d: Boolean) { a as Interface2? b as Interface1 val x = when (d) { true -> a false -> b } x.apply { this as Interface3 this if (this != null) { this this.equals(null) this.propT this.propAny this.propNullableT this.propNullableAny this.funT() this.funAny() this.funNullableT() this.funNullableAny() this.itest1() this.itest2() } } x.let { it as Interface3 it if (it != null) { it it.equals(null) it.propT it.propAny it.propNullableT it.propNullableAny it.funT() it.funAny() it.funNullableT() it.funNullableAny() it.itest1() it.itest2() } } } /* * TESTCASE NUMBER: 7 * ISSUES: KT-28670 */ fun case_7(a: Interface1?, b: Interface2?, d: Boolean) { a as Interface2? b as Interface1? val x = when (d) { true -> a false -> b } x.apply { this as Interface3? this if (this != null) { this this.equals(null) this.propT this.propAny this.propNullableT this.propNullableAny this.funT() this.funAny() this.funNullableT() this.funNullableAny() this.itest1() this.itest2() } } x.let { it as Interface3? it if (it != null) { it it.equals(null) it.propT it.propAny it.propNullableT it.propNullableAny it.funT() it.funAny() it.funNullableT() it.funNullableAny() it.itest1() it.itest2() } } }