Skip to content

🍒[cxx-interop] Look up NSNotificationName in C++ language mode properly #68279

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

Merged
merged 2 commits into from
Sep 2, 2023

Conversation

egorzhdan
Copy link
Contributor

This change makes sure that NSNotification.Name.NEVPNStatusDidChange is imported correctly when C++ interop is enabled.

importer::findSwiftNewtype is called while writing Clang modules, at a point when the translation-unit scope does not exist (clangSema.TUScope is nullptr).

That prevents the Clang lookup from discovering NSNotificationName declaration.

Instead of trying to pass a translation-unit scope to Clang, let's use qualified name lookup which does not require a scope.

Original PR: #68217

rdar://112199372

This change makes sure that `NSNotification.Name.NEVPNStatusDidChange` is imported correctly when C++ interop is enabled.

`importer::findSwiftNewtype` is called while writing Clang modules, at a point when the translation-unit scope does not exist (`clangSema.TUScope` is `nullptr`).

That prevents the Clang lookup from discovering `NSNotificationName` declaration.

Instead of trying to pass a translation-unit scope to Clang, let's use qualified name lookup which does not require a scope.

rdar://112199372
(cherry picked from commit e956e8a)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Sep 1, 2023
@egorzhdan egorzhdan requested a review from a team as a code owner September 1, 2023 20:12
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan merged commit 94f8edd into release/5.9 Sep 2, 2023
@egorzhdan egorzhdan deleted the egorzhdan/5.9-nsnotification branch September 2, 2023 18:13
@yousofno
Copy link

is it fixed in Xcode 15 right now? , because i have this problem

@yousofno
Copy link

never mind , i have fixed it with adding
extension NSNotification.Name {
static let NEVPNStatusDidChange = NSNotification.Name("com.apple.networkextension.statuschanged")
}
into my code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants