Skip to content

computeMissingCases

Computes the missing cases of the given KtWhenExpression.

The computed missing cases are not affected by the existence or absence of an else branch.

Example

In the following code, Direction.WEST and Direction.EAST are missing branches:

enum class Direction {
  NORTH, SOUTH, WEST, EAST
}

foo = when(direction) {
  Direction.NORTH -> 1
  Direction.SOUTH -> 2
  else -> 3
}

If the KtWhenExpression has no subject, then the else is reported as missing even if it is explicitly present:

fun test() {
    when {
        true -> {}
        else -> {}
    }
}