报告会在 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
}
从 1.7 版开始,可对 Kotlin 语言级别进行检查。