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(
10300
10300
if (!importedDC) return nullptr ;
10301
10301
10302
10302
// 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;
10306
10308
10307
10309
// If the resulting declaration context is not a nominal type,
10308
10310
// we're done.
Original file line number Diff line number Diff line change @@ -25,3 +25,8 @@ typedef MyNS::MyDeepNS::DeepNestedStruct DeepNestedStructTypedef;
25
25
26
26
int deepNestedStructTypedef_method (DeepNestedStructTypedef p) SWIFT_NAME(" DeepNestedStructTypedef.methodTypedef(self:)" ) { return p.value + 3 ; }
27
27
int 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 4
4
// CHECK-NEXT: func method() -> Int32
5
5
// CHECK-NEXT: func methodConstRef() -> Int32
6
6
// CHECK-NEXT: func methodInline() -> Int32
7
+ // CHECK-NEXT: func nestedMethod() -> Int32
8
+ // CHECK-NEXT: func nestedMethodInline() -> Int32
7
9
// CHECK-NEXT: }
8
10
9
11
// CHECK: extension MyNS.MyDeepNS.DeepNestedStruct {
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import ImportAsMember
5
5
func takesNestedStruct( _ s: MyNS . NestedStruct ) {
6
6
_ = s. method ( )
7
7
_ = s. methodConstRef ( )
8
+ _ = s. nestedMethod ( )
9
+ _ = s. nestedMethodInline ( )
8
10
9
11
_ = nestedStruct_method ( s) // expected-error {{'nestedStruct_method' has been replaced by instance method 'MyNS.NestedStruct.method()'}}
10
12
}
@@ -17,3 +19,6 @@ func takesDeepNestedStruct(_ s: MyNS.MyDeepNS.DeepNestedStruct) {
17
19
18
20
_ = deepNestedStruct_method ( s) // expected-error {{'deepNestedStruct_method' has been replaced by instance method 'MyNS.MyDeepNS.DeepNestedStruct.method()'}}
19
21
}
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") {
22
22
expectEqual ( 460 , s. methodTypedefQualName ( ) )
23
23
}
24
24
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
+
25
31
runAllTests ( )
You can’t perform that action at this time.
0 commit comments