Kotlin 1.8 以降でコンパイルエラーを引き起こす when 分岐内のあいまいな論理式を報告します。


  fun Int.matches(strict: Boolean): Boolean = when (strict) {
      true -> this == 6
      this in (4..7) -> true // あいまいです
      else -> false
  }

クイックフィックス適用後:


  fun Int.matches(strict: Boolean): Boolean = when (strict) {
      true -> this == 6
      (this in (4..7)) -> true // 丸括弧で囲まれました
      else -> false
  }

このインスペクションは Kotlin の言語レベルが 1.7 以降の場合に使用できます。