Front-end test data fixed to have no complex patterns
#KT-2359 In Progress
This commit is contained in:
@@ -12,18 +12,9 @@ fun foo() : Int {
|
||||
1 + <!UNRESOLVED_REFERENCE!>a<!> -> 1
|
||||
in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1
|
||||
!in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1
|
||||
// Commented for KT-621 .<!!UNRESOLVED_REFERENCE!>a<!!> => 1
|
||||
// Commented for KT-621 .equals(1).<!!UNRESOLVED_REFERENCE!>a<!!> => 1
|
||||
// Commented for KT-621 <!UNNECESSARY_SAFE_CALL!!>?.<!!>equals(1) => 1
|
||||
is * -> 1
|
||||
else -> 1
|
||||
}
|
||||
|
||||
// Commented for KT-621
|
||||
// return when (<!!USELESS_ELVIS!>x<!!>?:null) {
|
||||
// <!!UNSAFE_CALL!!>.<!!>foo() => 1
|
||||
// .equals(1) => 1
|
||||
// ?.equals(1).equals(2) => 1
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -35,27 +26,16 @@ fun test() {
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
<!INCOMPATIBLE_TYPES!>s<!> -> 1
|
||||
is <!INCOMPATIBLE_TYPES!>""<!> -> 1
|
||||
<!INCOMPATIBLE_TYPES!>""<!> -> 1
|
||||
x -> 1
|
||||
is 1 -> 1
|
||||
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, 1)<!> -> 1
|
||||
1 -> 1
|
||||
}
|
||||
|
||||
val z = #(1, 1)
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (z) {
|
||||
is #(*, *) -> 1
|
||||
is #(*, 1) -> 1
|
||||
is #(1, 1) -> 1
|
||||
is #(1, <!INCOMPATIBLE_TYPES!>"1"<!>) -> 1
|
||||
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, "1", *)<!> -> 1
|
||||
is boo #(1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) -> 1
|
||||
is boo <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, *)<!> -> 1
|
||||
}
|
||||
val z = 1
|
||||
|
||||
when (z) {
|
||||
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> 1
|
||||
<!UNREACHABLE_CODE!>#(1, 1) -> 2<!>
|
||||
<!UNREACHABLE_CODE!>1 -> 2<!>
|
||||
}
|
||||
|
||||
when (z) {
|
||||
|
||||
@@ -9,11 +9,8 @@ fun foo() =
|
||||
<!TYPE_MISMATCH_IN_CONDITION!>#(1, 2)<!> -> 3
|
||||
<!EXPECTED_CONDITION!>in 1..10<!> -> 34
|
||||
<!TYPE_MISMATCH_IN_CONDITION!>4<!> -> 38
|
||||
<!EXPECTED_CONDITION!>is val a in 1..10<!> -> 23
|
||||
<!EXPECTED_CONDITION!>is Int<!> -> 33
|
||||
<!EXPECTED_CONDITION!>is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(val a, 3)<!><!> -> 2
|
||||
<!EXPECTED_CONDITION!>!is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(*, 1100)<!><!> -> 3
|
||||
<!EXPECTED_CONDITION!>is *<!> -> 34
|
||||
else -> 34
|
||||
}
|
||||
|
||||
fun cond1() = false
|
||||
|
||||
+6
-6
@@ -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 <!UNUSED_VARIABLE!>withWhen<!> : () -> Unit = {
|
||||
when(i) {
|
||||
is 1 -> {
|
||||
1 -> {
|
||||
val d = 34
|
||||
<!UNUSED_EXPRESSION!>"1"<!>
|
||||
doSmth(d)
|
||||
|
||||
}
|
||||
is 2 -> '4'
|
||||
2 -> '4'
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
@@ -87,13 +87,13 @@ fun testImplicitCoercion() {
|
||||
val d = 21
|
||||
var z = 0
|
||||
var <!UNUSED_VARIABLE!>i<!> = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>when(d) {
|
||||
is 3 -> null
|
||||
is 4 -> { val <!NAME_SHADOWING, UNUSED_VARIABLE!>z<!> = 23 }
|
||||
3 -> null
|
||||
4 -> { val <!NAME_SHADOWING, UNUSED_VARIABLE!>z<!> = 23 }
|
||||
else -> z = 20
|
||||
}<!>
|
||||
|
||||
var <!UNUSED_VARIABLE!>u<!> = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>when(d) {
|
||||
is 3 -> {
|
||||
3 -> {
|
||||
z = <!UNUSED_VALUE!>34<!>
|
||||
}
|
||||
else -> <!UNUSED_CHANGED_VALUE!>z--<!>
|
||||
|
||||
@@ -5,7 +5,7 @@ fun foo() : Int {
|
||||
val d = 2
|
||||
var z = 0
|
||||
when(d) {
|
||||
is 5, is 3 -> <!UNUSED_CHANGED_VALUE!>z++<!>
|
||||
5, 3 -> <!UNUSED_CHANGED_VALUE!>z++<!>
|
||||
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> { z = <!UNUSED_VALUE!>-1000<!> }
|
||||
<!UNREACHABLE_CODE!>return z -> 34<!>
|
||||
}
|
||||
@@ -15,7 +15,7 @@ fun foo() : Int {
|
||||
fun fff(): Int {
|
||||
var d = 3
|
||||
<!NO_ELSE_IN_WHEN!>when<!>(d) {
|
||||
is 4 -> 21
|
||||
4 -> 21
|
||||
return 2 -> <!UNREACHABLE_CODE!>return 47<!>
|
||||
<!UNREACHABLE_CODE!>bar() -> 45<!>
|
||||
<!UNREACHABLE_CODE!>444 -> true<!>
|
||||
|
||||
@@ -6,14 +6,14 @@ package kt234_kt973
|
||||
|
||||
fun test(t : #(Int, Int)) : Int {
|
||||
<!NO_ELSE_IN_WHEN!>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
|
||||
}
|
||||
<!UNREACHABLE_CODE!>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
|
||||
<!UNREACHABLE_CODE!>2 -> 2<!>
|
||||
}
|
||||
|
||||
fun t4(x: Int) = when (x) {
|
||||
is val a -> 1
|
||||
<!UNREACHABLE_CODE!>2 -> 2<!>
|
||||
else -> 1
|
||||
}
|
||||
|
||||
fun t5(x: Int) = <!NO_ELSE_IN_WHEN!>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
|
||||
}
|
||||
|
||||
@@ -68,27 +68,23 @@ fun f12(a : A?) {
|
||||
is A -> a.foo()
|
||||
is Any -> a.foo();
|
||||
is Any? -> a.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
is val c : <!TYPE_MISMATCH_IN_BINDING_PATTERN!>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?.<!UNRESOLVED_REFERENCE!>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()
|
||||
<!UNRESOLVED_REFERENCE!>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()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val x is C)) {
|
||||
<!UNRESOLVED_REFERENCE, UNUSED_EXPRESSION!>x<!>
|
||||
<!UNRESOLVED_REFERENCE, UNUSED_EXPRESSION!>c<!>
|
||||
if (!(a is B) || !(a is C)) {
|
||||
}
|
||||
else {
|
||||
<!UNRESOLVED_REFERENCE, UNUSED_EXPRESSION!>x<!>
|
||||
<!UNRESOLVED_REFERENCE, UNUSED_EXPRESSION!>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()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
fun f14(a : A?) {
|
||||
while (!(a is val c is B)) {
|
||||
while (!(a is B)) {
|
||||
}
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
fun f15(a : A?) {
|
||||
do {
|
||||
} while (!(a is val c is B))
|
||||
} while (!(a is B))
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
fun getStringLength(obj : Any) : Char? {
|
||||
@@ -213,8 +201,6 @@ fun returnFunctionLiteral(a: Any?): Function0<Int> =
|
||||
|
||||
fun illegalTupleReturnType(a: Any): #(Any, String) = #(a, <!TYPE_MISMATCH!>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.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
|
||||
@@ -12,17 +12,9 @@ fun foo() : Int {
|
||||
1 + <error>a</error> -> 1
|
||||
in 1..<error>a</error> -> 1
|
||||
!in 1..<error>a</error> -> 1
|
||||
// Commented for KT-621 .<!error>a</!error> -> 1
|
||||
// Commented for KT-621 .equals(1).<!error>a</!error> -> 1
|
||||
// Commented for KT-621 <!warning>?.</!warning>equals(1) -> 1
|
||||
is * -> 1
|
||||
else -> 1
|
||||
}
|
||||
|
||||
// Commented for KT-621
|
||||
// return when (<!warning>x</!warning>?:null) {
|
||||
// <!error>.</!error>foo() -> 1
|
||||
// ?.equals(1).equals(2) -> 1
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -34,29 +26,17 @@ fun test() {
|
||||
|
||||
when (x) {
|
||||
<error>s</error> -> 1
|
||||
is <error>""</error> -> 1
|
||||
<error>""</error> -> 1
|
||||
x -> 1
|
||||
is 1 -> 1
|
||||
is <error>#(1, 1)</error> -> 1
|
||||
1 -> 1
|
||||
else -> 1
|
||||
}
|
||||
|
||||
val z = #(1, 1)
|
||||
|
||||
when (z) {
|
||||
is #(*, *) -> 1
|
||||
is #(*, 1) -> 1
|
||||
is #(1, 1) -> 1
|
||||
is #(1, <error>"1"</error>) -> 1
|
||||
is <error>#(1, "1", *)</error> -> 1
|
||||
is boo #(1, <error>"a"</error>, *) -> 1
|
||||
is boo <error>#(1, *)</error> -> 1
|
||||
else -> 1
|
||||
}
|
||||
val z = 1
|
||||
|
||||
when (z) {
|
||||
<error>else</error> -> 1
|
||||
<error>#(1, 1) -> 2</error>
|
||||
<error>1 -> 2</error>
|
||||
}
|
||||
|
||||
when (z) {
|
||||
|
||||
@@ -66,27 +66,22 @@ fun f12(a : A?) {
|
||||
is A -> <info descr="Automatically cast to A">a</info>.foo()
|
||||
is Any -> <info descr="Automatically cast to A">a</info>.foo();
|
||||
is Any? -> a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
|
||||
is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B is not a supertype of A?. Use 'is' to match against B">B</error> -> c.foo()
|
||||
is val c is C -> <info descr="Automatically cast to C">c</info>.bar()
|
||||
is val c is C -> <info descr="Automatically cast to C">a</info>.bar()
|
||||
is C -> <info descr="Automatically cast to C">a</info>.bar()
|
||||
else -> a<info>?.</info>foo()
|
||||
}
|
||||
|
||||
if (a is val b) {
|
||||
if (a is Any?) {
|
||||
a<info>?.</info><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
|
||||
b<info>?.</info>foo()
|
||||
}
|
||||
if (a is val b is B) {
|
||||
<info descr="Automatically cast to B">b</info>.foo()
|
||||
if (a is B) {
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<info descr="Automatically cast to B">b</info>.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun f13(a : A?) {
|
||||
if (a is val c is B) {
|
||||
<info descr="Automatically cast to B">c</info>.foo()
|
||||
<info descr="Automatically cast to B">c</info>.bar()
|
||||
if (a is B) {
|
||||
<info descr="Automatically cast to B">a</info>.foo()
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
}
|
||||
else {
|
||||
a<info>?.</info>foo()
|
||||
@@ -94,54 +89,43 @@ fun f13(a : A?) {
|
||||
}
|
||||
|
||||
a<info>?.</info>foo()
|
||||
if (!(a is val c is B)) {
|
||||
if (!(a is B)) {
|
||||
a<info>?.</info>foo()
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
else {
|
||||
<info descr="Automatically cast to B">a</info>.foo()
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
a<info>?.</info>foo()
|
||||
if (a is val c is B && <info descr="Automatically cast to B">a</info>.foo() == #() && <info descr="Automatically cast to B">c</info>.bar() == #()) {
|
||||
<info descr="Automatically cast to B">c</info>.foo()
|
||||
<info descr="Automatically cast to B">c</info>.bar()
|
||||
if (a is B && <info descr="Automatically cast to B">a</info>.foo() == #()) {
|
||||
<info descr="Automatically cast to B">a</info>.foo()
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
}
|
||||
else {
|
||||
a<info>?.</info>foo()
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val x is C)) {
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: x">x</error>
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>
|
||||
if (!(a is B) || !(a is C)) {
|
||||
}
|
||||
else {
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: x">x</error>
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>
|
||||
}
|
||||
|
||||
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
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.foo()
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
fun f14(a : A?) {
|
||||
while (!(a is val c is B)) {
|
||||
while (!(a is B)) {
|
||||
}
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
fun f15(a : A?) {
|
||||
do {
|
||||
} while (!(a is val c is B))
|
||||
} while (!(a is B))
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
fun getStringLength(obj : Any) : Char? {
|
||||
@@ -213,8 +197,6 @@ fun returnFunctionLiteral(<info>a</info>: Any?): Function0<Int> =
|
||||
|
||||
fun illegalTupleReturnType(a: Any): #(Any, String) = #(a, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is jet.Any but jet.String was expected">a</error>)
|
||||
|
||||
fun declarationInsidePattern(x: #(Any, Any)): String = when(x) { is #(val a is String, *) -> <info descr="Automatically cast to jet.String">a</info>; else -> "something" }
|
||||
|
||||
fun mergeAutocasts(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
||||
|
||||
Reference in New Issue
Block a user