Skip to content

Commit 94f8edd

Browse files
authored
Merge pull request #68279 from apple/egorzhdan/5.9-nsnotification
πŸ’[cxx-interop] Look up `NSNotificationName` in C++ language mode properly
2 parents 7062f6f + 62bc51b commit 94f8edd

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

β€Žlib/ClangImporter/ClangAdapter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,9 @@ clang::TypedefNameDecl *importer::findSwiftNewtype(const clang::NamedDecl *decl,
555555
clang::LookupResult lookupResult(clangSema, notificationName,
556556
clang::SourceLocation(),
557557
clang::Sema::LookupOrdinaryName);
558-
if (!clangSema.LookupName(lookupResult, clangSema.TUScope))
558+
if (!clangSema.LookupQualifiedName(
559+
lookupResult,
560+
/*LookupCtx*/ clangSema.getASTContext().getTranslationUnitDecl()))
559561
return nullptr;
560562
auto nsDecl = lookupResult.getAsSingle<clang::TypedefNameDecl>();
561563
if (!nsDecl)

β€Žtest/Interop/Cxx/objc-correctness/Inputs/module.modulemap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module NSOptionsMangling {
1717
header "NSOptionsMangling.h"
1818
}
1919

20-
module NSNofiticationBridging {
20+
module NSNotificationBridging {
2121
header "nsnotification-bridging.h"
2222
requires objc
2323
requires cplusplus
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#import <Foundation/Foundation.h>
22

33
extern NSString * const SpaceShipNotification;
4+
extern "C" NSString * const CExternNotification;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// RUN: %target-swift-ide-test -print-module -module-to-print=NSNofiticationBridging -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop -enable-objc-interop | %FileCheck %s
1+
// RUN: %target-swift-ide-test -print-module -module-to-print=NSNotificationBridging -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop -enable-objc-interop | %FileCheck %s
22

33
// REQUIRES: objc_interop
44

55
// CHECK: import Foundation
66

77
// CHECK: let SpaceShipNotification: String
8+
// CHECK: let CExternNotification: String
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -enable-objc-interop -enable-experimental-cxx-interop
2+
// REQUIRES: objc_interop
3+
4+
import Foundation
5+
import NSNotificationBridging
6+
7+
func test(_ n: NSNotification.Name) {}
8+
9+
test(NSNotification.Name.SpaceShip)
10+
test(NSNotification.Name.CExtern)

0 commit comments

Comments
Β (0)