Skip to content

Commit f31291e

Browse files
authored
Merge pull request #69776 from apple/egorzhdan/reland-nsnotificationname-lookup
Revert "Revert "[cxx-interop] Look up `NSNotificationName` in C++ language mode properly""
2 parents 753faaf + be24236 commit f31291e

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

lib/ClangImporter/ClangAdapter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,9 @@ clang::TypedefNameDecl *importer::findSwiftNewtype(const clang::NamedDecl *decl,
560560
clang::LookupResult lookupResult(clangSema, notificationName,
561561
clang::SourceLocation(),
562562
clang::Sema::LookupOrdinaryName);
563-
if (!clangSema.LookupName(lookupResult, clangSema.TUScope))
563+
if (!clangSema.LookupQualifiedName(
564+
lookupResult,
565+
/*LookupCtx*/ clangSema.getASTContext().getTranslationUnitDecl()))
564566
return nullptr;
565567
auto nsDecl = lookupResult.getAsSingle<clang::TypedefNameDecl>();
566568
if (!nsDecl)
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;

test/Interop/Cxx/objc-correctness/nsnotification-bridging-ide-test.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
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)