// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_VARIABLE -UNUSED_VALUE // SKIP_TXT /* * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) * * SECTIONS: dfa * NUMBER: 51 * DESCRIPTION: Raw data flow analysis test * HELPERS: classes, objects, typealiases, functions, enumClasses, interfaces, sealedClasses */ // TESTCASE NUMBER: 1 fun case_1(x: Any?) { val y = run { if (x is Class) return@run x Class() } y y.fun_1() } // TESTCASE NUMBER: 2 fun case_2(x: Class?) { val y = run { x!! return@run x } y y.fun_1() } // TESTCASE NUMBER: 3 fun case_3(z: Any?) { val y = run { when (z) { is Class? -> z!! is Class -> return@run z is Float -> Class() else -> return@run Class() } } y y.fun_1() } // TESTCASE NUMBER: 4 fun case_4(z: Any?) { val y = run { when (z) { is Class? -> z!! is Class -> return@run z is Float -> Class() else -> return@run Class() } Class() } y y.fun_1() } // TESTCASE NUMBER: 5 fun case_5(z: Any?) { val y = run { when (z) { is Class? -> z!! is Class -> return@run z is Float -> Class() else -> return@run Class() } "" } y y.equals(10) } // TESTCASE NUMBER: 6 fun case_6(z: Any?) { val y = z.let { when (it) { is Class? -> it!! is Class -> return@let it is Float -> Class() else -> return@let Class() } } y y.fun_1() } // TESTCASE NUMBER: 7 fun case_7(z: Any?) { val y = z.let { it as Class } y y.fun_1() } // TESTCASE NUMBER: 8 fun case_8(z: Any?) { val y = z.let { return@let it as Class } y y.fun_1() } // TESTCASE NUMBER: 9 fun case_9(z: Any?) { val y = z.run { this as Class } y y.fun_1() } // TESTCASE NUMBER: 10 fun case_10(z: Any?) { val y = z.run { return@run this as Class } y y.fun_1() } // TESTCASE NUMBER: 11 fun case_11(z: Any?, x: Any?) { val y = z.let { if (it is ClassLevel6) return@let it x as ClassLevel3 } y y.test3() } // TESTCASE NUMBER: 12 fun case_12(z: Any?) { val y = z.let { return@let it as Int it as? Float ?: 10f } & Number}")!>y & Number}")!>y.toByte() } /* * TESTCASE NUMBER: 13 * ISSUES: KT-30927 */ fun case_13(z: Any?) { val y = z.run { if (this is ClassLevel6) return@run this this as ClassLevel3 } y y.test3() } // TESTCASE NUMBER: 14 fun case_14(z: Any?) { val y = z.run { return@run this as Int this as? Float ?: 10f } & Number}")!>y & Number}")!>y.toByte() } /* * TESTCASE NUMBER: 15 * NOTE: 'Any' is common super type between kotlin.Unit (obtained using coersion to Unit) and Int */ fun case_15(z: Any?) { val y = z.let { return@let it as Int while (true) { println(1) } } y y.equals(10) } /* * TESTCASE NUMBER: 16 * NOTE: 'Any' is common super type between kotlin.Unit (obtained using coersion to Unit) and Int */ fun case_16(z: Any?) { val y = z.run { return@run this as Int while (true) { println(1) } } y y.equals(10) } /* * TESTCASE NUMBER: 17 * ISSUES: KT-30927 */ fun case_17(z: Any?) { val y = z.run { when (this) { is Class? -> this!! is Class -> return@run this is Float -> Class() else -> return@run Class() } } y y.fun_1() } /* * TESTCASE NUMBER: 18 * ISSUES: KT-30927 */ fun case_18(z: Any?) { val y = z.run { this as Int this } y y.inv() } // TESTCASE NUMBER: 19 fun case_19(z: Any?) { val y = z.let { it as Int it } y y.inv() } /* * TESTCASE NUMBER: 20 * ISSUES: KT-30927 */ fun case_20(z: Any?) { val y = z.run { this!! this } y y.equals(10) } // TESTCASE NUMBER: 21 fun case_21(z: Any?) { val y = z.run { if (true) this as Any else this!! } y y.equals(10) } // TESTCASE NUMBER: 22 fun case_22(z: Any?) { val y = z.let { if (true) it as Any else it!! } y y.equals(10) } // TESTCASE NUMBER: 23 fun case_23(z: Any?) { val y = z.run { when (this) { true -> this!! 0.0 -> this as Any else -> this!! } } y y.equals(10) } // TESTCASE NUMBER: 24 fun case_24(z: Any?) { val y = z.let { when (it) { true -> it!! 0.0 -> it as Any else -> it!! } } y y.equals(10) } // TESTCASE NUMBER: 25 fun case_25(z: Any?) { val y = z.run { when (this) { true -> this if (true) this as Int else this as Float -> this return@run this as Float -> this else -> this!! } } y y.equals(10) } // TESTCASE NUMBER: 26 fun case_26(z: Any?) { val y = z.let { when (it) { true -> it if (true) it as Int else it as Float -> it return@let it as Int -> it else -> it!! } } y y.equals(10) } // TESTCASE NUMBER: 27 fun case_27(z: Any?) { val y = z.let { if (it == null) return@let Any() it } y y.equals(10) } /* * TESTCASE NUMBER: 28 * ISSUES: KT-30927 */ fun case_28(z: Any?) { val y = z.run { if (this == null) throw IllegalStateException() this } y y.equals(10) } // TESTCASE NUMBER: 29 fun case_29(z: Any?) { val y = z.let { if (it == null) throw IllegalStateException() it } y y.equals(10) }