diff --git a/compiler/testData/diagnostics/tests/When.kt b/compiler/testData/diagnostics/tests/When.kt index f0003081614..50410cb1647 100644 --- a/compiler/testData/diagnostics/tests/When.kt +++ b/compiler/testData/diagnostics/tests/When.kt @@ -12,18 +12,9 @@ fun foo() : Int { 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 - is * -> 1 + else -> 1 } - // Commented for KT-621 - // return when (x?:null) { - // .foo() => 1 - // .equals(1) => 1 - // ?.equals(1).equals(2) => 1 - // } return 0 } @@ -35,27 +26,16 @@ fun test() { when (x) { s -> 1 - is "" -> 1 + "" -> 1 x -> 1 - is 1 -> 1 - is #(1, 1) -> 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 - } + val z = 1 when (z) { else -> 1 - #(1, 1) -> 2 + 1 -> 2 } when (z) { diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt657.kt b/compiler/testData/diagnostics/tests/controlStructures/kt657.kt index f4c95003d08..bab366fb5df 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt657.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt657.kt @@ -9,11 +9,8 @@ fun foo() = #(1, 2) -> 3 in 1..10 -> 34 4 -> 38 - is val a in 1..10 -> 23 is Int -> 33 - is #(val a, 3) -> 2 - !is #(*, 1100) -> 3 - is * -> 34 + else -> 34 } fun cond1() = false diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt index 185316295ed..42eda55853b 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt @@ -34,7 +34,7 @@ fun box() : Int { val d = 2 var z = 0 when(d) { - is 5, is 3 -> z++ + 5, 3 -> z++ else -> z = -1000 } return z @@ -59,13 +59,13 @@ fun testCoercionToUnit() { val i = 34 val withWhen : () -> Unit = { when(i) { - is 1 -> { + 1 -> { val d = 34 "1" doSmth(d) } - is 2 -> '4' + 2 -> '4' else -> true } } @@ -87,13 +87,13 @@ fun testImplicitCoercion() { val d = 21 var z = 0 var i = when(d) { - is 3 -> null - is 4 -> { val z = 23 } + 3 -> null + 4 -> { val z = 23 } else -> z = 20 } var u = when(d) { - is 3 -> { + 3 -> { z = 34 } else -> z-- diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt786.kt b/compiler/testData/diagnostics/tests/controlStructures/kt786.kt index 68cc6879269..8240606300d 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt786.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt786.kt @@ -5,7 +5,7 @@ fun foo() : Int { val d = 2 var z = 0 when(d) { - is 5, is 3 -> z++ + 5, 3 -> z++ else -> { z = -1000 } return z -> 34 } @@ -15,7 +15,7 @@ fun foo() : Int { fun fff(): Int { var d = 3 when(d) { - is 4 -> 21 + 4 -> 21 return 2 -> return 47 bar() -> 45 444 -> true diff --git a/compiler/testData/diagnostics/tests/controlStructures/when.kt234.kt973.kt b/compiler/testData/diagnostics/tests/controlStructures/when.kt234.kt973.kt index d0d2650b707..ff227c754f5 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/when.kt234.kt973.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/when.kt234.kt973.kt @@ -6,14 +6,14 @@ package kt234_kt973 fun test(t : #(Int, Int)) : Int { when (t) { - is #(10, 10) -> return 1 + #(10, 10) -> return 1 } return 0 // unreachable code } fun test1(t : #(Int, Int)) : Int { when (t) { - is #(10, 10) -> return 1 + #(10, 10) -> return 1 else -> return 2 } return 0 // unreachable code @@ -21,25 +21,11 @@ fun test1(t : #(Int, Int)) : Int { //more tests fun t1(x: Int) = when(x) { - is * -> 1 -} - -fun t2(x: Int) = when(x) { - is val a -> 1 -} - -fun t3(x: Int) = when (x) { - is * -> 1 - 2 -> 2 -} - -fun t4(x: Int) = when (x) { - is val a -> 1 - 2 -> 2 + else -> 1 } fun t5(x: Int) = when (x) { - is val a : Int -> 1 + is Int -> 1 2 -> 2 } @@ -50,5 +36,5 @@ fun foo3(x: Int) = when(x) { fun foo4(x: Int) = when(x) { 2 -> x - is val a -> a + else -> 3 } diff --git a/compiler/testData/diagnostics/tests/infos/Autocasts.kt b/compiler/testData/diagnostics/tests/infos/Autocasts.kt index 83accb4f1e1..2cd34dd2ef8 100644 --- a/compiler/testData/diagnostics/tests/infos/Autocasts.kt +++ b/compiler/testData/diagnostics/tests/infos/Autocasts.kt @@ -68,27 +68,23 @@ fun f12(a : A?) { is A -> a.foo() is Any -> a.foo(); is Any? -> a.bar() - is val c : B -> c.foo() - is val c is C -> c.bar() - is val c is C -> a.bar() + is C -> a.bar() else -> a?.foo() } - if (a is val b) { + if (a is Any?) { a?.bar() - b?.foo() } - if (a is val b is B) { - b.foo() + if (a is B) { + a.foo() a.bar() - b.bar() } } fun f13(a : A?) { - if (a is val c is B) { - c.foo() - c.bar() + if (a is B) { + a.foo() + a.bar() } else { a?.foo() @@ -96,7 +92,7 @@ fun f13(a : A?) { } a?.foo() - if (!(a is val c is B)) { + if (!(a is B)) { a?.foo() c.bar() } @@ -106,44 +102,36 @@ fun f13(a : A?) { } a?.foo() - if (a is val c is B && a.foo() == #() && c.bar() == #()) { - c.foo() - c.bar() + if (a is B && a.foo() == #()) { + a.foo() + a.bar() } else { a?.foo() c.bar() } - if (!(a is val c is B) || !(a is val x is C)) { - x - c + if (!(a is B) || !(a is C)) { } else { - x - c } - if (!(a is val c is B) || !(a is val c is C)) { + if (!(a is B) || !(a is C)) { } - if (!(a is val c is B)) return + if (!(a is B)) return a.bar() - c.foo() - c.bar() } fun f14(a : A?) { - while (!(a is val c is B)) { + while (!(a is B)) { } a.bar() - c.bar() } fun f15(a : A?) { do { - } while (!(a is val c is B)) + } while (!(a is B)) a.bar() - c.bar() } fun getStringLength(obj : Any) : Char? { @@ -213,8 +201,6 @@ fun returnFunctionLiteral(a: Any?): Function0 = fun illegalTupleReturnType(a: Any): #(Any, String) = #(a, a) -fun declarationInsidePattern(x: #(Any, Any)): String = when(x) { is #(val a is String, *) -> a; else -> "something" } - fun mergeAutocasts(a: Any?) { if (a is String || a is Int) { a.compareTo("") diff --git a/idea/testData/checker/When.jet b/idea/testData/checker/When.jet index c4bf4638653..70e7a0b0148 100644 --- a/idea/testData/checker/When.jet +++ b/idea/testData/checker/When.jet @@ -12,17 +12,9 @@ fun foo() : Int { 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 - is * -> 1 + else -> 1 } - // Commented for KT-621 - // return when (x?:null) { - // .foo() -> 1 - // ?.equals(1).equals(2) -> 1 - // } return 0 } @@ -34,29 +26,17 @@ fun test() { when (x) { s -> 1 - is "" -> 1 + "" -> 1 x -> 1 - is 1 -> 1 - is #(1, 1) -> 1 + 1 -> 1 else -> 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 - else -> 1 - } + val z = 1 when (z) { else -> 1 - #(1, 1) -> 2 + 1 -> 2 } when (z) { diff --git a/idea/testData/checker/infos/Autocasts.jet b/idea/testData/checker/infos/Autocasts.jet index 656518e9b3d..53601579ce3 100644 --- a/idea/testData/checker/infos/Autocasts.jet +++ b/idea/testData/checker/infos/Autocasts.jet @@ -66,27 +66,22 @@ fun f12(a : A?) { is A -> a.foo() is Any -> a.foo(); is Any? -> a.bar() - is val c : B -> c.foo() - is val c is C -> c.bar() - is val c is C -> a.bar() + is C -> a.bar() else -> a?.foo() } - if (a is val b) { + if (a is Any?) { a?.bar() - b?.foo() } - if (a is val b is B) { - b.foo() + if (a is B) { a.bar() - b.bar() } } fun f13(a : A?) { - if (a is val c is B) { - c.foo() - c.bar() + if (a is B) { + a.foo() + a.bar() } else { a?.foo() @@ -94,54 +89,43 @@ fun f13(a : A?) { } a?.foo() - if (!(a is val c is B)) { + if (!(a is B)) { a?.foo() - c.bar() } else { a.foo() - c.bar() } a?.foo() - if (a is val c is B && a.foo() == #() && c.bar() == #()) { - c.foo() - c.bar() + if (a is B && a.foo() == #()) { + a.foo() + a.bar() } else { a?.foo() - c.bar() } - if (!(a is val c is B) || !(a is val x is C)) { - x - c + if (!(a is B) || !(a is C)) { } else { - x - c } - if (!(a is val c is B) || !(a is val c is C)) { + if (!(a is B) || !(a is C)) { } - if (!(a is val c is B)) return + if (!(a is B)) return a.bar() - c.foo() - c.bar() } fun f14(a : A?) { - while (!(a is val c is B)) { + while (!(a is B)) { } a.bar() - c.bar() } fun f15(a : A?) { do { - } while (!(a is val c is B)) + } while (!(a is B)) a.bar() - c.bar() } fun getStringLength(obj : Any) : Char? { @@ -213,8 +197,6 @@ fun returnFunctionLiteral(a: Any?): Function0 = fun illegalTupleReturnType(a: Any): #(Any, String) = #(a, a) -fun declarationInsidePattern(x: #(Any, Any)): String = when(x) { is #(val a is String, *) -> a; else -> "something" } - fun mergeAutocasts(a: Any?) { if (a is String || a is Int) { a.compareTo("")