Reports a non-exhaustive when statements that will lead to compilation error since 1.7.

Motivation types:

Impact types:

More details: KT-47709: Make when statements with enum, sealed, and Boolean subjects exhaustive by default

The quick-fix adds the missing else -> {} branch.

Example:


  sealed class Base {
      class A : Base()
      class B : Base()
  }

  fun test(base: Base) {
      when (base) {
          is Base.A -> ""
      }
  }

After the quick-fix is applied:


  sealed class Base {
      class A : Base()
      class B : Base()
  }

  fun test(base: Base) {
      when (base) {
          is Base.A -> ""
          else -> {}
      }
  }

This inspection only reports if the Kotlin language level of the project or module is 1.6 or higher.