@@ -333,26 +333,15 @@ static ManagedValue emitManagedParameter(SILGenFunction &SGF, SILLocation loc,
333333 llvm_unreachable (" bad convention" );
334334}
335335
336- static void expandTupleTypes (CanType type, SmallVectorImpl<CanType> &results) {
337- if (auto tuple = dyn_cast<TupleType>(type)) {
338- for (auto eltType : tuple.getElementTypes ())
339- expandTupleTypes (eltType, results);
340- } else {
341- results.push_back (type);
342- }
343- }
344-
345- // / Recursively expand all the tuples in the given parameter list.
346- // / Callers assume that the resulting array will line up with the
347- // / SILFunctionType's parameter list, which is true as along as there
348- // / aren't any indirectly-passed tuples; we should be safe from that
349- // / here in the bridging code.
336+ // / Get the type of each parameter, filtering out empty tuples.
350337static SmallVector<CanType, 8 >
351- expandTupleTypes (AnyFunctionType::CanParamArrayRef params) {
338+ getParameterTypes (AnyFunctionType::CanParamArrayRef params) {
352339 SmallVector<CanType, 8 > results;
353340 for (auto param : params) {
354341 assert (!param.isInOut () && !param.isVariadic ());
355- expandTupleTypes (param.getPlainType (), results);
342+ if (param.getPlainType ()->isVoid ())
343+ continue ;
344+ results.push_back (param.getPlainType ());
356345 }
357346 return results;
358347}
@@ -403,8 +392,8 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
403392 assert (blockTy->getParameters ().size () == funcTy->getParameters ().size ()
404393 && " block and function types don't match" );
405394
406- auto nativeParamTypes = expandTupleTypes (formalFuncType.getParams ());
407- auto bridgedParamTypes = expandTupleTypes (formalBlockType.getParams ());
395+ auto nativeParamTypes = getParameterTypes (formalFuncType.getParams ());
396+ auto bridgedParamTypes = getParameterTypes (formalBlockType.getParams ());
408397
409398 SmallVector<ManagedValue, 4 > args;
410399 for (unsigned i : indices (funcTy->getParameters ())) {
@@ -839,8 +828,8 @@ static void buildBlockToFuncThunkBody(SILGenFunction &SGF,
839828 }
840829 }
841830
842- auto formalBlockParams = expandTupleTypes (formalBlockTy.getParams ());
843- auto formalFuncParams = expandTupleTypes (formalFuncTy.getParams ());
831+ auto formalBlockParams = getParameterTypes (formalBlockTy.getParams ());
832+ auto formalFuncParams = getParameterTypes (formalFuncTy.getParams ());
844833 assert (formalBlockParams.size () == blockTy->getNumParameters ());
845834 assert (formalFuncParams.size () == funcTy->getNumParameters ());
846835
@@ -1297,10 +1286,10 @@ static SILFunctionType *emitObjCThunkArguments(SILGenFunction &SGF,
12971286 assert (objcFnTy->getNumIndirectFormalResults () == 0
12981287 && " Objective-C methods cannot have indirect results" );
12991288
1300- auto bridgedFormalTypes = expandTupleTypes (objcFormalFnTy.getParams ());
1289+ auto bridgedFormalTypes = getParameterTypes (objcFormalFnTy.getParams ());
13011290 bridgedFormalResultTy = objcFormalFnTy.getResult ();
13021291
1303- auto nativeFormalTypes = expandTupleTypes (swiftFormalFnTy.getParams ());
1292+ auto nativeFormalTypes = getParameterTypes (swiftFormalFnTy.getParams ());
13041293 nativeFormalResultTy = swiftFormalFnTy.getResult ();
13051294
13061295 // Emit the other arguments, taking ownership of arguments if necessary.
@@ -1697,9 +1686,9 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
16971686
16981687 {
16991688 auto foreignFormalParams =
1700- expandTupleTypes (foreignCI.LoweredType .getParams ());
1689+ getParameterTypes (foreignCI.LoweredType .getParams ());
17011690 auto nativeFormalParams =
1702- expandTupleTypes (nativeCI.LoweredType .getParams ());
1691+ getParameterTypes (nativeCI.LoweredType .getParams ());
17031692
17041693 for (unsigned nativeParamIndex : indices (params)) {
17051694 // Bring the parameter to +1.
0 commit comments