此检查可识别下述方法调用,其中可能为 null 的实参被传递给使用 @NotNull 注解的形参,有助于在运行时发生潜在的 NullPointerExceptions 之前检测到这些异常。
示例:
def test(@Nullable greeting: String): Unit = {
sayHello(greeting)
}
def sayHello(@NotNull greeting: String): Unit = {
println(greeting.toLowerCase)
}