-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Nullability #399
base: master
Are you sure you want to change the base?
Adds Nullability #399
Conversation
self = [super init]; | ||
if (!self) return nil; | ||
if (!self) return self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit awkward, i know, but otherwise the compiler will complain that the method should not return nil
due to nullability.
@@ -14,6 +14,8 @@ | |||
*/ | |||
@interface MASViewAttribute : NSObject | |||
|
|||
NS_ASSUME_NONNULL_BEGIN | |||
|
|||
/** | |||
* The view which the reciever relates to. Can be nil if item is not a view. | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, actually the view can be nil according to the comment, need to fix this in a new commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, fixed it. fixed also the designated initializer which allows view
to be nil
too. did not fix the convenience initializer, as view
ist used for both view
and item
there, and item
may not be nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually now did fix the convenience initializer, as the item
property is weak
and thus needs to be nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i mean, it could be forced that the parameter is non-nil in the initializer, and the property still can become nullable - but as the MASConstraintDelegateMock
explicitly passes nil
, I went with making it nullable.
In this case either you change the method to expect a nil return value or you throw an exception there... Both options may not be viable, but I personally find it very dangerous to have methods disobey their public API contracts. The compiler is right in this case. Sent from my iPhone
|
@Panajev:
This is exactly the same - also returns |
…ies which cannot be nullable and other parameters that are explicitly allowed to be nil from the context
No more
make?
inside blocks.