Does the Objective-C compiler actually warn you if it thinks that you may be passing nil
to a parameter marked with _Nonnull
?
Or is it merely a hint to whatever tool converts between Swift and Objective-C to better deal with Swift optionals?
Does the Objective-C compiler actually warn you if it thinks that you may be passing nil
to a parameter marked with _Nonnull
?
Or is it merely a hint to whatever tool converts between Swift and Objective-C to better deal with Swift optionals?
Copyright © 2021 Jogjafile Inc.
On its own, there is warning only in the extremely trivial case: when you pass
nil
to a function accepting_Nonnull
value.(There is a
-Wnullable-to-nonnull-conversion
flag but it doesn't seem to have any effect to the code above.)As documented, the three attributes will not change the behavior of the code:
Beyond the compiler, it will also help the static analyzer, but again clang's static analyzer will only catch the trivial case where it knows for sure you are assigning a
nil
to a_Nonnull
(i.e. thetest(f)
example above).Nevertheless, it is still useful to mark a pointer
_Nonnull
/_Nullable
as