Skip to content

Commit 43bac74

Browse files
committed
Use correct param index when bridging params
1 parent a0e15ae commit 43bac74

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,22 +4112,26 @@ TypeConverter::getLoweredFormalTypes(SILDeclRef constant,
41124112
}
41134113
}
41144114

4115-
// C++ operators that are implemented as non-static member functions get
4116-
// imported into Swift as static methods that have an additional
4117-
// parameter for the left-hand-side operand instead of the receiver object.
4118-
// These are inout parameters and don't get bridged.
4119-
// TODO: Undo this if we stop using inout.
4120-
if (auto method = dyn_cast_or_null<clang::CXXMethodDecl>(
4121-
constant.getDecl()->getClangDecl())) {
4122-
if (method->isOverloadedOperator()) {
4123-
bridgedParams.push_back(methodParams[0]);
4124-
methodParams = methodParams.drop_front(1);
4115+
auto partialFnPattern = bridgingFnPattern.getFunctionResultType();
4116+
for (unsigned i : indices(methodParams)) {
4117+
// C++ operators that are implemented as non-static member functions get
4118+
// imported into Swift as static methods that have an additional
4119+
// parameter for the left-hand-side operand instead of the receiver
4120+
// object. These are inout parameters and don't get bridged.
4121+
// TODO: Undo this if we stop using inout.
4122+
if (auto method = dyn_cast_or_null<clang::CXXMethodDecl>(
4123+
constant.getDecl()->getClangDecl())) {
4124+
if (i==0 && method->isOverloadedOperator()) {
4125+
bridgedParams.push_back(methodParams[0]);
4126+
continue;
4127+
}
41254128
}
4126-
}
41274129

4128-
auto partialFnPattern = bridgingFnPattern.getFunctionResultType();
4129-
getBridgedParams(rep, partialFnPattern, methodParams, bridgedParams,
4130-
bridging);
4130+
auto paramPattern = partialFnPattern.getFunctionParamType(i);
4131+
auto bridgedParam =
4132+
getBridgedParam(rep, paramPattern, methodParams[i], bridging);
4133+
bridgedParams.push_back(bridgedParam);
4134+
}
41314135

41324136
bridgedResultType =
41334137
getBridgedResultType(rep,

0 commit comments

Comments
 (0)