Created attachment 17499
sample case
Adding nullability annotations to ObjC source for correct interoperability with
Swift is made more difficult by the inability of clang to detect if a method
might return nil even if it says it doesn't.
clang apparently has a -Wnullable-to-nonnull-conversion flag to detect cases
like this. While it works for code like:
- (nonnull NSString *)ok:(nullable NSString *)arg;
{
return arg;
}
it is trivially confused by:
- (nonnull NSString *)bad:(nullable NSString *)arg;
{
// BAD: nullable value returned to a non-nullable result
NSString *result = arg;
return result;
}
Example file attached with a couple variants.
nonnull-conversion.m
(1132 bytes, application/octet-stream)