Disallow non-nullable argument in function with nullable argument
Hello
I faintly remember coming across a way to trigger a compiler error/warning when calling a function expecting an argument of a nullable type (e.g., Any?) with an argument of a non-nullable type (e.g., Any), but I’m unable to google it now…
For example:
fun rejectIfNull(value: Any?) { // how can I statically disallow Any here?
if (value == null) {
// do something
}
}
rejectIfNull("I'm not null") // should generate a compiler error/warning
Is that possible? Thank you for your...