Skip to content

Fix nullability of Network browse results handler arguments - #889

Open
LucaCappelletti94 wants to merge 1 commit into
madsmtm:mainfrom
LucaCappelletti94:upstream/network-browse-result-nullability
Open

LucaCappelletti94 wants to merge 1 commit into
madsmtm:mainfrom
LucaCappelletti94:upstream/network-browse-result-nullability

Conversation

@LucaCappelletti94

@LucaCappelletti94 LucaCappelletti94 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

nw_browser_browse_results_changed_handler_t sits inside NW_ASSUME_NONNULL_BEGIN, so objc2-network typed its old and new results as NonNull<NWBrowseResult>. Network passes NULL as the old result when a service appears and as the new result when it disappears, which is why nw_browse_result_get_changes takes both as _Nullable.

I saw it with a Bonjour listener and browser on macOS 26.7.1, iOS 26.6.2 and iPadOS 26.6.2, where every added and removed result handed the closure a NULL NonNull. I reported the header's annotation to Apple as FB25452730.

The translation config had no way to change the nullability of a block typedef's parameters, so typedef.<name>.arguments.<index> now takes the same overrides as function arguments, and the Network config uses it for the two results. The handler now takes *mut NWBrowseResult for both. The regenerated file is on the upstream/network-browse-result-nullability branch of my objc2-generated fork.

This fixes the nullability half only. The typedef still cannot be built from a closure, since its trailing C bool is not EncodeArgument, the limitation discussed in #752.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant