Our current handling of nullability of interop types are inconsistent:
|
if (returnType.isPotentiallyNonNullable) { |
|
if (!callbackParameterType.isPotentiallyNullable) { |
In the callback parameter case, we add a null-check if the type is not potentially nullable, and in the return type case, we add a null-check if the type is potentially non-nullable. Both only handle some of the cases correctly. The right alternative for both cases is if the nullability is Nullability.nonNullable, place a null-check, and if it's Nullability.undetermined, cast.