File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed
test/Interop/Cxx/templates Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -3326,6 +3326,14 @@ namespace {
3326
3326
continue ;
3327
3327
}
3328
3328
3329
+ if (auto recordDecl = dyn_cast<clang::RecordDecl>(m)) {
3330
+ // An injected class name decl will just point back to the parent
3331
+ // decl, so don't import it.
3332
+ if (recordDecl->isInjectedClassName ()) {
3333
+ continue ;
3334
+ }
3335
+ }
3336
+
3329
3337
auto nd = dyn_cast<clang::NamedDecl>(m);
3330
3338
if (!nd) {
3331
3339
// We couldn't import the member, so we can't reference it in Swift.
@@ -3569,6 +3577,19 @@ namespace {
3569
3577
return VisitCXXRecordDecl (def);
3570
3578
}
3571
3579
3580
+ Decl *VisitClassTemplateDecl (const clang::ClassTemplateDecl *decl) {
3581
+ // When loading a namespace's sub-decls, we won't add template
3582
+ // specilizations, so make sure to do that here.
3583
+ for (auto spec : decl->specializations ()) {
3584
+ if (auto importedSpec = Impl.importDecl (spec, getVersion ())) {
3585
+ if (auto namespaceDecl =
3586
+ dyn_cast<EnumDecl>(importedSpec->getDeclContext ()))
3587
+ namespaceDecl->addMember (importedSpec);
3588
+ }
3589
+ }
3590
+ return nullptr ;
3591
+ }
3592
+
3572
3593
Decl *VisitClassTemplatePartialSpecializationDecl (
3573
3594
const clang::ClassTemplatePartialSpecializationDecl *decl) {
3574
3595
// Note: partial template specializations are not imported.
Original file line number Diff line number Diff line change
1
+ namespace Space {
2
+
3
+ template <class ...> struct Ship ;
4
+ template <class T , class ... Args> struct Ship <T(Args...)> {};
5
+
6
+ using Orbiter = Ship<void (bool )>;
7
+
8
+ } // namespace Space
Original file line number Diff line number Diff line change @@ -57,3 +57,7 @@ module ClassTemplateTemplateParameter {
57
57
module ClassTemplateWithTypedef {
58
58
header "class-template-with-typedef.h"
59
59
}
60
+
61
+ module ClassTemplateInNamespace {
62
+ header "class-template-in-namespace.h"
63
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-ide-test -print-module -module-to-print=ClassTemplateInNamespace -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s
2
+
3
+ // CHECK: enum Space {
4
+ // CHECK: struct __CxxTemplateInstN5Space4ShipIJFvbEEEE {
5
+ // CHECK: init()
6
+ // CHECK: }
7
+ // CHECK: typealias Orbiter = Space.__CxxTemplateInstN5Space4ShipIJFvbEEEE
8
+ // CHECK: }
You can’t perform that action at this time.
0 commit comments