swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.5k stars 10.35k forks source link

[SR-9789] Use "pretty" nullability in generated ObjC headers #52214

Open belkadan opened 5 years ago

belkadan commented 5 years ago
Previous ID SR-9789
Radar None
Original Reporter @belkadan
Type Improvement
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Improvement, PrintAsObjC, StarterBug | |Assignee | @adellibovi | |Priority | Medium | md5: 0bc925759fd7590c0a91c67c7a5de68f

Issue Description:

Objective-C supports two "pretty" forms for nullability qualifiers: within the parentheses of a method's parameters or return type:

- (id _Nullable)computate:(int * _Nonnull)values;

- (nullable id)computate:(nonnull int *)values;

And in the property attributes list for a property:

@property id _Nullable owner;

@property (nullable) id owner;

PrintAsObjC should adopt these where valid; right now it only uses them in hardcoded cases for instancetype.

belkadan commented 5 years ago

Part of rdar://problem/47493396. I think this is StarterBug-able: find all the places where we're using the getObjectTypeAndOptionality helper and see which ones are places where we could print the nullability separately using NullabilityPrintKind::ContextSensitive.

adellibovi commented 5 years ago

hi @belkadan, I would like to take this one, can I assign it to myself? 🙂

belkadan commented 5 years ago

Go for it! Feel free to comment here if you have questions, or open a partial PR even if you don't have it fully working.

belkadan commented 5 years ago

@adellibovi, still working on this one?

(I'm checking in on all the StarterBugs that haven't been touched in over a month; it's totally fine if you just haven't had time but still want to keep it.)