diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 8cede95fbb98b..7c6fb37883606 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -3732,7 +3732,8 @@ namespace { ParameterList *getNonSelfParamList( DeclContext *dc, const clang::FunctionDecl *decl, Optional selfIdx, ArrayRef argNames, - bool allowNSUIntegerAsInt, bool isAccessor) { + bool allowNSUIntegerAsInt, bool isAccessor, + ArrayRef genericParams) { if (bool(selfIdx)) { assert(((decl->getNumParams() == argNames.size() + 1) || isAccessor) && (*selfIdx < decl->getNumParams()) && "where's self?"); @@ -3748,7 +3749,7 @@ namespace { } return Impl.importFunctionParameterList( dc, decl, nonSelfParams, decl->isVariadic(), allowNSUIntegerAsInt, - argNames, /*genericParams=*/{}); + argNames, genericParams); } Decl *importGlobalAsInitializer(const clang::FunctionDecl *decl, @@ -3886,7 +3887,7 @@ namespace { bodyParams = getNonSelfParamList(dc, decl, selfIdx, name.getArgumentNames(), - allowNSUIntegerAsInt, !name); + allowNSUIntegerAsInt, !name, templateParams); importedType = Impl.importFunctionReturnType(dc, decl, allowNSUIntegerAsInt); diff --git a/test/Interop/Cxx/templates/Inputs/function-templates.h b/test/Interop/Cxx/templates/Inputs/function-templates.h index a86c070e08a1c..8b3dfb52f3e42 100644 --- a/test/Interop/Cxx/templates/Inputs/function-templates.h +++ b/test/Interop/Cxx/templates/Inputs/function-templates.h @@ -52,3 +52,16 @@ template void lvalueReference(T &ref) { ref = 42; } template void constLvalueReference(const T &) {} template void forwardingReference(T &&) {} + +namespace Orbiters { + +template +void galileo(T) { } + +template +void cassini(T, U) { } + +template +void magellan(T&) { } + +} diff --git a/test/Interop/Cxx/templates/function-template-module-interface.swift b/test/Interop/Cxx/templates/function-template-module-interface.swift index 72367a69523e2..b8307a70ee237 100644 --- a/test/Interop/Cxx/templates/function-template-module-interface.swift +++ b/test/Interop/Cxx/templates/function-template-module-interface.swift @@ -6,6 +6,13 @@ // CHECK: func passThroughConst(_ value: T) -> T // CHECK: func returns_template(_ a: T, _ b: U) -> R // CHECK: func cannot_infer_template() + // CHECK: func lvalueReference(_ ref: UnsafeMutablePointer) // CHECK: func constLvalueReference(_: UnsafePointer) // CHECK: func forwardingReference(_: UnsafeMutablePointer) + +// CHECK: enum Orbiters { +// CHECK: static func galileo(_: T) +// CHECK: static func cassini(_: T, _: U) +// CHECK: static func magellan(_: UnsafeMutablePointer) +// CHECK: }