Skip to content

Commit c027b9d

Browse files
committed
[interop] emit symbolic interfaces with method signatures with matching parameter count
We do not care about parameter's type in the symbolic method declaration, but we do care about the arity of the method. (cherry picked from commit 991d0a7)
1 parent c28d0b2 commit c027b9d

6 files changed

+29
-8
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3249,7 +3249,26 @@ namespace {
32493249
} else {
32503250
if (importFuncWithoutSignature) {
32513251
importedType = ImportedType{Impl.SwiftContext.getVoidType(), false};
3252-
bodyParams = ParameterList::createEmpty(Impl.SwiftContext);
3252+
if (decl->param_empty())
3253+
bodyParams = ParameterList::createEmpty(Impl.SwiftContext);
3254+
else {
3255+
llvm::SmallVector<ParamDecl *, 4> params;
3256+
for (const auto &param : decl->parameters()) {
3257+
3258+
Identifier bodyName =
3259+
Impl.importFullName(param, Impl.CurrentVersion)
3260+
.getDeclName()
3261+
.getBaseIdentifier();
3262+
auto paramInfo = Impl.createDeclWithClangNode<ParamDecl>(
3263+
param, AccessLevel::Private, SourceLoc(), SourceLoc(),
3264+
Identifier(), Impl.importSourceLoc(param->getLocation()),
3265+
bodyName, Impl.ImportedHeaderUnit);
3266+
paramInfo->setSpecifier(ParamSpecifier::Default);
3267+
paramInfo->setInterfaceType(Impl.SwiftContext.TheAnyType);
3268+
params.push_back(paramInfo);
3269+
}
3270+
bodyParams = ParameterList::create(Impl.SwiftContext, params);
3271+
}
32533272
} else {
32543273
// Import the function type. If we have parameters, make sure their
32553274
// names get into the resulting function type.

test/Interop/Cxx/symbolic-imports/indexing-emit-objcxx-symbolic-module-interface.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// Verify that symbolic interface is not emitted without interop.
1010
//
1111
// RUN: rm -r %t/store/interfaces
12-
// RUN: %target-swift-frontend %t/test.swift -I %t -c -index-system-modules -index-store-path %t/store -Rindexing-system-module 2>&1 | %FileCheck --check-prefix=REMARK_NONE %s
12+
// RUN: %target-swift-frontend %t/test.swift -I %t -c -index-system-modules -index-store-path %t/store -Rindexing-system-module 2>&1 > %t/out
13+
// RUN: echo "non-empty-file-check" >> %t/out
14+
// RUN: cat %t/out | %FileCheck --check-prefix=REMARK_NONE %s
1315
// RUN: not ls %t/store/interfaces
1416

1517
// REQUIRES: objc_interop

test/Interop/Cxx/symbolic-imports/indexing-emit-symbolic-module-interface-used-decls.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public func useConcreteTemplate() {
3535
// CHECK-EMPTY:
3636
// CHECK-NEXT: public struct TemplateRecord {
3737
// CHECK-EMPTY:
38-
// CHECK-NEXT: public func methodFunc()
38+
// CHECK-NEXT: public func methodFunc(_ x: Any)
3939
// CHECK-NEXT:}
4040
// CHECK-NEXT:}
4141
// CHECK-NEXT: public typealias TemplateRecordInt = ns.TemplateRecord

test/Interop/Cxx/symbolic-imports/indexing-emit-symbolic-module-interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ import CxxModule
123123
// CHECK-EMPTY:
124124
// CHECK-NEXT: struct TemplateRecord {
125125
// CHECK-EMPTY:
126-
// CHECK-NEXT: mutating func methodFunc()
126+
// CHECK-NEXT: mutating func methodFunc(_ x: Any)
127127
// CHECK-EMPTY:
128128
// CHECK-NEXT: struct InnerRecord {
129129
// CHECK-EMPTY:
130-
// CHECK-NEXT: mutating func innerMethod()
130+
// CHECK-NEXT: mutating func innerMethod(_ y: Any)
131131
// CHECK-NEXT: }
132132
// CHECK-EMPTY:
133133
// CHECK-NEXT: struct InnerTemplate {

test/Interop/Cxx/symbolic-imports/print-libcxx-symbolic-module-interface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// STRING: typealias string = std.__1.basic_string
1616

1717
// VECTOR: struct vector {
18-
// VECTOR: mutating func push_back()
18+
// VECTOR: mutating func push_back(_ __x: Any)
1919
// VECTOR: }
2020

2121
// MAP: struct map {

test/Interop/Cxx/symbolic-imports/print-symbolic-module-interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ using MyType = ns::TemplateRecord<int>;
5252
// CHECK-NEXT: var y: Int32
5353
// CHECK-NEXT: }
5454
// CHECK-NEXT: struct TemplateRecord {
55-
// CHECK-NEXT: mutating func methodFunc()
55+
// CHECK-NEXT: mutating func methodFunc(_ x: Any)
5656
// CHECK-NEXT: struct InnerRecord {
57-
// CHECK-NEXT: mutating func innerMethod()
57+
// CHECK-NEXT: mutating func innerMethod(_ y: Any)
5858
// CHECK-NEXT: }
5959
// CHECK-NEXT: struct InnerTemplate {
6060
// CHECK-NEXT: mutating func innerTemplateMethod()

0 commit comments

Comments
 (0)