Why does Kotlin create null checks on null-safe parameters but not on null-safe returns?

I would say that returns are trusted because the compiler ensures that the function returns the correct type.
However, that is not the case for parameters because in Java you could pass a null value to a Kotlin function that only accepts non-null values, and the Java compiler wouldn’t complain.
To prevent this the Kotlin compiler inserts null checks for each non-null parameter, allowing the function to be called from any language while enforcing the nullability rules.

2 Likes