File tree Expand file tree Collapse file tree 5 files changed +23
-3
lines changed
test/Interop/Cxx/namespace Expand file tree Collapse file tree 5 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -10300,9 +10300,11 @@ ClangImporter::Implementation::importDeclContextOf(
1030010300 if (!importedDC) return nullptr ;
1030110301
1030210302 // If the declaration was not global to start with, we're done.
10303- bool isGlobal =
10304- decl->getDeclContext ()->getRedeclContext ()->isTranslationUnit ();
10305- if (!isGlobal) return importedDC;
10303+ bool isRenamedGlobal =
10304+ decl->getDeclContext ()->getRedeclContext ()->isTranslationUnit () ||
10305+ (context.getKind () == EffectiveClangContext::UnresolvedContext &&
10306+ decl->getDeclContext ()->getRedeclContext ()->isNamespace ());
10307+ if (!isRenamedGlobal) return importedDC;
1030610308
1030710309 // If the resulting declaration context is not a nominal type,
1030810310 // we're done.
Original file line number Diff line number Diff line change @@ -25,3 +25,8 @@ typedef MyNS::MyDeepNS::DeepNestedStruct DeepNestedStructTypedef;
2525
2626int deepNestedStructTypedef_method (DeepNestedStructTypedef p) SWIFT_NAME(" DeepNestedStructTypedef.methodTypedef(self:)" ) { return p.value + 3 ; }
2727int deepNestedStructTypedef_methodQualName (MyNS::MyDeepNS::DeepNestedStruct p) SWIFT_NAME(" DeepNestedStructTypedef.methodTypedefQualName(self:)" ) { return p.value + 4 ; }
28+
29+ namespace MyNS {
30+ int nestedStruct_nestedMethod (MyNS::NestedStruct p) SWIFT_NAME(" MyNS.NestedStruct.nestedMethod(self:)" ) { return p.value + 3 ; }
31+ inline int nestedStruct_nestedMethodInline (MyNS::NestedStruct p) SWIFT_NAME(" MyNS.NestedStruct.nestedMethodInline(self:)" ) { return p.value + 4 ; }
32+ }
Original file line number Diff line number Diff line change 44// CHECK-NEXT: func method() -> Int32
55// CHECK-NEXT: func methodConstRef() -> Int32
66// CHECK-NEXT: func methodInline() -> Int32
7+ // CHECK-NEXT: func nestedMethod() -> Int32
8+ // CHECK-NEXT: func nestedMethodInline() -> Int32
79// CHECK-NEXT: }
810
911// CHECK: extension MyNS.MyDeepNS.DeepNestedStruct {
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import ImportAsMember
55func takesNestedStruct( _ s: MyNS . NestedStruct ) {
66 _ = s. method ( )
77 _ = s. methodConstRef ( )
8+ _ = s. nestedMethod ( )
9+ _ = s. nestedMethodInline ( )
810
911 _ = nestedStruct_method ( s) // expected-error {{'nestedStruct_method' has been replaced by instance method 'MyNS.NestedStruct.method()'}}
1012}
@@ -17,3 +19,6 @@ func takesDeepNestedStruct(_ s: MyNS.MyDeepNS.DeepNestedStruct) {
1719
1820 _ = deepNestedStruct_method ( s) // expected-error {{'deepNestedStruct_method' has been replaced by instance method 'MyNS.MyDeepNS.DeepNestedStruct.method()'}}
1921}
22+
23+ MyNS . method ( ) // expected-error {{type 'MyNS' has no member 'method'}}
24+ MyNS . nestedMethod ( ) // expected-error {{type 'MyNS' has no member 'nestedMethod'}}
Original file line number Diff line number Diff line change @@ -22,4 +22,10 @@ NamespacesTestSuite.test("Struct in a deep namespace") {
2222 expectEqual ( 460 , s. methodTypedefQualName ( ) )
2323}
2424
25+ NamespacesTestSuite . test ( " Struct and function in a namespace " ) {
26+ let s = MyNS . NestedStruct ( )
27+ expectEqual ( 126 , s. nestedMethod ( ) )
28+ expectEqual ( 127 , s. nestedMethodInline ( ) )
29+ }
30+
2531runAllTests ( )
You can’t perform that action at this time.
0 commit comments