error(...) 的非 null 断言 (!!) 调用。
非 null 断言可能导致意想不到的 NPE (NullPointerException)。 将其替换为 ?: error(...) 会使失败显现出来,并支持整个文件的检查清理。
示例:
fun test(number: Int?) {
val x = number!!
}
在应用快速修复后:
fun test(number: Int?) {
val x = number ?: error("Expression 'number' must not be null")
}