Skip to content

Commit a1f9aae

Browse files
committed
[cxx-interop] Fix integer substitution on watchOS.
Basically watchOS had the same issue as Windows.
1 parent 283fc78 commit a1f9aae

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,7 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
236236
newFn));
237237

238238
if (auto fn = dyn_cast<AbstractFunctionDecl>(newDecl)) {
239-
// On Windows x86-64 we have to hack around the fact that
240-
// Int -> long long -> Int64. So we re-write the parameters mapping
241-
// Int64 -> Int.
242-
auto triple = decl->getASTContext().LangOpts.Target;
243-
if (triple.isOSWindows() && triple.isArch64Bit() &&
244-
!triple.isWindowsCygwinEnvironment() &&
245-
// Make sure we're substituting in at least one Int or UInt
246-
// (technically not necessary).
247-
llvm::any_of(subst.getReplacementTypes(), [](Type t) {
248-
return t->isEqual(t->getASTContext().getIntType()) ||
249-
t->isEqual(t->getASTContext().getUIntType());
250-
})) {
239+
if (!subst.empty()) {
251240
auto originalFnSubst = cast<AbstractFunctionDecl>(decl)
252241
->getInterfaceType()
253242
->getAs<GenericFunctionType>()
@@ -301,7 +290,7 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
301290
/*genericParams=*/nullptr, func->getDeclContext(), newFn);
302291
if (func->isStatic()) newFnDecl->setStatic();
303292
if (func->isImportAsStaticMember()) newFnDecl->setImportAsStaticMember();
304-
if (!func->getDeclContext()->isModuleScopeContext()) {
293+
if (func->getImportAsMemberStatus().isInstance()) {
305294
newFnDecl->setSelfAccessKind(func->getSelfAccessKind());
306295
newFnDecl->setSelfIndex(func->getSelfIndex());
307296
}

test/Interop/Cxx/templates/member-templates-silgen.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func testStaticMembers() {
6868
HasStaticMemberTemplates.removeReference(&x)
6969
}
7070

71-
// CHECK: sil [clang HasStaticMemberTemplates.add] @_ZN24HasStaticMemberTemplates3addIlEET_S1_S1_ : $@convention(c) (Int, Int) -> Int
71+
// CHECK: sil {{(hidden_external)?}} [clang HasStaticMemberTemplates.add] @_ZN24HasStaticMemberTemplates3addIlEET_S1_S1_ : $@convention(c) (Int, Int) -> Int
7272

73-
// CHECK: sil [clang HasStaticMemberTemplates.addTwoTemplates] @_ZN24HasStaticMemberTemplates15addTwoTemplatesIlcEET_S1_T0_ : $@convention(c) (Int, Int8) -> Int
73+
// CHECK: sil {{(hidden_external)?}} [clang HasStaticMemberTemplates.addTwoTemplates] @_ZN24HasStaticMemberTemplates15addTwoTemplatesIlcEET_S1_T0_ : $@convention(c) (Int, Int8) -> Int
7474

75-
// CHECK: sil [clang HasStaticMemberTemplates.removeReference] @_ZN24HasStaticMemberTemplates15removeReferenceIlEET_RS1_ : $@convention(c) (@inout Int) -> Int
75+
// CHECK: sil {{(hidden_external)?}} [clang HasStaticMemberTemplates.removeReference] @_ZN24HasStaticMemberTemplates15removeReferenceIlEET_RS1_ : $@convention(c) (@inout Int) -> Int

0 commit comments

Comments
 (0)