Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Conversation

@tomquist
Copy link

This pull request adds generics to all Array/Set/Dictionary methods and nullability modifiers in a backward compatible way.

@tomquist tomquist changed the title Add (backward compatible) generic parametrization Add (backward compatible) generic parametrization and nullability Dec 15, 2015
@orta
Copy link
Contributor

orta commented Mar 5, 2016

This is awesome, I want this, @supermarin can we get this merged and a release made please? In #101 you said you were waiting on this for a release 👯

@supermarin
Copy link
Owner

Thank you @tomquist for the great work and @orta for pinging.
My GH notifications are so noisy that I unfortunately missed the opening of this PR.

I checked out and verified this code, and the same compiler bugs are still there since time I was trying to get this achieved.

Namely, if you look at this test it should warn or fail the compilation.
I did amend the test code locally and can confirm that this is not the case.

Regardless of the fact above, I'm in favor of merging this as the compiler bug (nullability validation in Objc blocks) is not ObjectiveSugar's fault and might be resolved on it's own. Until then, this is pretty useless unless I'm doing something wrong.

Before merging, @tomquist would you mind updating the test code / project settings to affect your changes and use the nullability stuff?

On the side note, I'd even be open of removing the compatibility stuff and just rolling the Generics/Nullability for 2.0.

@tomquist
Copy link
Author

tomquist commented Mar 7, 2016

@supermarin Could you please further explain what nullability validation bug you mean. I enabled nullability warnings in the project and updated the test code to use the nullability stuff. However, I get warnings as expected. The test you mentioned doesn't produce a warning because I declared the return value of the map method of NSArray to be nullable. This is something we probably should discuss.

In contrast to NSArray I declared the return value for map of NSSet and NSDictionary to be nonnull because they just emit nil values and NSArray converts them to NSNull

@supermarin
Copy link
Owner

I think map should be nonnull in both cases, leaving it to the user to return a NSNull if they want (which I doubt anyone wants). If you change map to return a nonnull block result and still access a dictionary element (like user[@"name"]), there's no warnings whereas one would be expected.

@tomquist
Copy link
Author

tomquist commented Mar 7, 2016

Maybe I didn't fully understand the issue but I get a warning for the case you explained, no issue here:

Btw. I'm happy to remove the compatibility stuff. Commit will follow

@orta
Copy link
Contributor

orta commented Mar 10, 2016

👍 ace

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants