Existing tests updated according to "'Else' is not required in 'when' if Unit is expected"
This commit is contained in:
@@ -17,7 +17,7 @@ fun testUnresolved() {
|
|||||||
foo1(<!UNRESOLVED_REFERENCE!>i<!>)
|
foo1(<!UNRESOLVED_REFERENCE!>i<!>)
|
||||||
s.<!UNRESOLVED_REFERENCE!>foo<!>()
|
s.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||||
|
|
||||||
<!NO_ELSE_IN_WHEN!>when<!>(<!UNRESOLVED_REFERENCE!>a<!>) {
|
when(<!UNRESOLVED_REFERENCE!>a<!>) {
|
||||||
is Int -> <!UNRESOLVED_REFERENCE!>a<!>
|
is Int -> <!UNRESOLVED_REFERENCE!>a<!>
|
||||||
is String -> <!UNRESOLVED_REFERENCE!>a<!>
|
is String -> <!UNRESOLVED_REFERENCE!>a<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ fun foo() : Int {
|
|||||||
//test unreachable code
|
//test unreachable code
|
||||||
fun fff(): Int {
|
fun fff(): Int {
|
||||||
var d = 3
|
var d = 3
|
||||||
<!NO_ELSE_IN_WHEN!>when<!>(d) {
|
when(d) {
|
||||||
4 -> 21
|
4 -> 21
|
||||||
return 2 -> <!UNREACHABLE_CODE!>return 47<!>
|
return 2 -> <!UNREACHABLE_CODE!>return 47<!>
|
||||||
<!UNREACHABLE_CODE!>bar() -> 45<!>
|
<!UNREACHABLE_CODE!>bar() -> 45<!>
|
||||||
@@ -23,4 +23,4 @@ fun fff(): Int {
|
|||||||
return 34
|
return 34
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(): Int = 8
|
fun bar(): Int = 8
|
||||||
@@ -6,7 +6,7 @@ package kt234_kt973
|
|||||||
class Pair<A, B>(a: A, b: B)
|
class Pair<A, B>(a: A, b: B)
|
||||||
|
|
||||||
fun test(t : Pair<Int, Int>) : Int {
|
fun test(t : Pair<Int, Int>) : Int {
|
||||||
<!NO_ELSE_IN_WHEN!>when<!> (t) {
|
when (t) {
|
||||||
Pair(10, 10) -> return 1
|
Pair(10, 10) -> return 1
|
||||||
}
|
}
|
||||||
return 0 // unreachable code
|
return 0 // unreachable code
|
||||||
@@ -38,4 +38,4 @@ fun foo3(x: Int) = when(x) {
|
|||||||
fun foo4(x: Int) = when(x) {
|
fun foo4(x: Int) = when(x) {
|
||||||
2 -> x
|
2 -> x
|
||||||
else -> 3
|
else -> 3
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ fun illegalWhenBody(a: Any): Int = <!NO_ELSE_IN_WHEN!>when<!>(a) {
|
|||||||
is String -> <!TYPE_MISMATCH!>a<!>
|
is String -> <!TYPE_MISMATCH!>a<!>
|
||||||
}
|
}
|
||||||
fun illegalWhenBlock(a: Any): Int {
|
fun illegalWhenBlock(a: Any): Int {
|
||||||
<!NO_ELSE_IN_WHEN!>when<!>(a) {
|
when(a) {
|
||||||
is Int -> return a
|
is Int -> return a
|
||||||
is String -> return <!TYPE_MISMATCH!>a<!>
|
is String -> return <!TYPE_MISMATCH!>a<!>
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ fun mergeAutocasts(a: Any?) {
|
|||||||
if (a is Int || a is String) {
|
if (a is Int || a is String) {
|
||||||
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||||
}
|
}
|
||||||
<!NO_ELSE_IN_WHEN!>when<!> (a) {
|
when (a) {
|
||||||
is String, is Any -> a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
is String, is Any -> a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||||
}
|
}
|
||||||
if (a is String && a is Any) {
|
if (a is String && a is Any) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//FILE: foo.kt
|
//FILE: foo.kt
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val c: Type
|
val c: Type
|
||||||
<!NO_ELSE_IN_WHEN!>when<!> (<!UNINITIALIZED_VARIABLE!>c<!>) {
|
when (<!UNINITIALIZED_VARIABLE!>c<!>) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ fun mergeAutocasts(a: Any?) {
|
|||||||
if (a is Int || a is String) {
|
if (a is Int || a is String) {
|
||||||
a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
||||||
}
|
}
|
||||||
<error>when</error> (a) {
|
when (a) {
|
||||||
is String, is Any -> a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
is String, is Any -> a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
||||||
}
|
}
|
||||||
if (a is String && a is Any) {
|
if (a is String && a is Any) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// "Add else branch" "true"
|
// "Add else branch" "true"
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = 12
|
val a = 12
|
||||||
when (a) {
|
val x = when (a) {
|
||||||
in 0..11 -> { /* some code */ }
|
in 0..11 -> { /* some code */ }
|
||||||
12, 13, 14 -> { /* some code */ }
|
12, 13, 14 -> { /* some code */ }
|
||||||
else -> {<caret>
|
else -> {<caret>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// "Add else branch" "true"
|
// "Add else branch" "true"
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = 12
|
val a = 12
|
||||||
when (a) {
|
val x = when (a) {
|
||||||
else -> {<caret>
|
else -> {<caret>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// "Add else branch" "true"
|
// "Add else branch" "true"
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = 12
|
val a = 12
|
||||||
wh<caret>en (a) {
|
val x = wh<caret>en (a) {
|
||||||
in 0..11 -> { /* some code */ }
|
in 0..11 -> { /* some code */ }
|
||||||
12, 13, 14 -> { /* some code */ }
|
12, 13, 14 -> { /* some code */ }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// "Add else branch" "true"
|
// "Add else branch" "true"
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = 12
|
val a = 12
|
||||||
wh<caret>en (a) {
|
val x = wh<caret>en (a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user