Skip to content

Commit 5361369

Browse files
authored
Merge pull request #41874 from zoecarver/find-ns-object-in-cxx-mode
[cxx-interop] Make sure to use TUScope when looking up clang decls.
2 parents 8f14e91 + 5db8647 commit 5361369

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3076,7 +3076,7 @@ Decl *ClangImporter::Implementation::importDeclByName(StringRef name) {
30763076
clang::LookupResult lookupResult(sema, clangName, clang::SourceLocation(),
30773077
clang::Sema::LookupOrdinaryName);
30783078
lookupResult.setAllowHidden(true);
3079-
if (!sema.LookupName(lookupResult, /*Scope=*/nullptr)) {
3079+
if (!sema.LookupName(lookupResult, /*Scope=*/sema.TUScope)) {
30803080
return nullptr;
30813081
}
30823082

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef TEST_INTEROP_CXX_CLASS_INPUTS_DESTRUCTORS_H
2+
#define TEST_INTEROP_CXX_CLASS_INPUTS_DESTRUCTORS_H
3+
4+
#import <Foundation/Foundation.h>
5+
6+
void takesDictionaryOfStrings(NSDictionary<NSString*, NSString*>*_Nonnull a) { }
7+
8+
#endif // TEST_INTEROP_CXX_CLASS_INPUTS_DESTRUCTORS_H

test/Interop/Cxx/class/Inputs/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,8 @@ module ClassProtocolNameClash {
9292
header "class-protocol-name-clash.h"
9393
requires cplusplus
9494
}
95+
96+
module DictionaryOfNSStrings {
97+
header "dictionary-of-nsstrings.h"
98+
requires cplusplus
99+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-swift-ide-test -print-module -module-to-print=DictionaryOfNSStrings -I %S/Inputs/ -source-filename=x -enable-cxx-interop | %FileCheck %s
2+
3+
// REQUIRES: objc_interop
4+
5+
// CHECK: func takesDictionaryOfStrings(_ a: [String : String])

0 commit comments

Comments
 (0)