Commit 07fcc4d
Normalize Objective-C nullability annotations (facebook#55898)
Summary:
Pull Request resolved: facebook#55898
Normalize Objective-C nullability annotations in the cxx-api parser to ensure consistent output in API snapshots.
Objective-C has three different forms of nullability annotations that are semantically equivalent:
- `nonnull`/`nullable` (context-sensitive keywords)
- `_Nonnull`/`_Nullable` (type qualifiers)
- `__nonnull`/`__nullable` (legacy Apple macros)
This diff normalizes all forms to `_Nonnull`/`_Nullable` for consistency.
**Examples:**
- `nonnull NSString*` → `_Nonnull NSString*`
- `NSString* __nonnull` → `NSString* _Nonnull`
- `nullable id` → `_Nullable id`
- `id __nullable` → `id _Nullable`
- `NSString* _Nonnull` → `NSString* _Nonnull` (unchanged)
Added a test case to verify the normalization works correctly.
Changelog:
[Internal]
Reviewed By: cortinico
Differential Revision: D951956691 parent d4f569c commit 07fcc4d
File tree
3 files changed
+68
-5
lines changed- scripts/cxx-api
- parser/utils
- tests/snapshots/should_normalize_nullability
3 files changed
+68
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
93 | 117 | | |
94 | 118 | | |
95 | 119 | | |
| |||
137 | 161 | | |
138 | 162 | | |
139 | 163 | | |
140 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
141 | 167 | | |
142 | 168 | | |
143 | | - | |
144 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
145 | 173 | | |
146 | 174 | | |
147 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
148 | 178 | | |
149 | 179 | | |
150 | 180 | | |
| |||
203 | 233 | | |
204 | 234 | | |
205 | 235 | | |
206 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
207 | 239 | | |
208 | 240 | | |
209 | 241 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments