fun Int.foo() : Boolean = true fun foo() : Int { val s = "" val x = 1 when (x) { is * => 1 is String => 1 !is Int => 1 is Any? => 1 s => 1 1 => 1 1 + a => 1 in 1..a => 1 !in 1..a => 1 // Commented for KT-621 .a => 1 // Commented for KT-621 .equals(1).a => 1 // Commented for KT-621 ?.equals(1) => 1 else => 1 } // Commented for KT-621 // return when (x?:null) { // .foo() => 1 // .equals(1) => 1 // ?.equals(1).equals(2) => 1 // } return 0 } val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo() fun test() { val x = 1; val s = ""; when (x) { s => 1 is "" => 1 x => 1 is 1 => 1 is (1, 1) => 1 } val z = (1, 1) when (z) { is (*, *) => 1 is (*, 1) => 1 is (1, 1) => 1 is (1, "1") => 1 is (1, "1", *) => 1 is boo @ (1, "a", *) => 1 is boo @ (1, *) => 1 } when (z) { else => 1 (1, 1) => 2 } when (z) { else => 1 } } val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1)