|
20 | 20 | //
|
21 | 21 | //===----------------------------------------------------------------------===//
|
22 | 22 |
|
| 23 | +#include "Callee.h" |
23 | 24 | #include "ManagedValue.h"
|
24 | 25 | #include "SILGenFunction.h"
|
25 | 26 | #include "SILGenFunctionBuilder.h"
|
@@ -198,12 +199,12 @@ static const clang::Type *prependParameterType(
|
198 | 199 | }
|
199 | 200 |
|
200 | 201 | SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction(
|
201 |
| - CanSILFunctionType blockType, CanType continuationTy, |
| 202 | + CanSILFunctionType blockType, CanType blockStorageType, |
202 | 203 | AbstractionPattern origFormalType, CanGenericSignature sig,
|
203 |
| - ForeignAsyncConvention convention, |
204 |
| - llvm::Optional<ForeignErrorConvention> foreignError) { |
205 |
| - // Extract the result and error types from the continuation type. |
206 |
| - auto resumeType = cast<BoundGenericType>(continuationTy).getGenericArgs()[0]; |
| 204 | + CalleeTypeInfo &calleeInfo) { |
| 205 | + auto convention = *calleeInfo.foreign.async; |
| 206 | + auto resumeType = |
| 207 | + calleeInfo.substResultType->mapTypeOutOfContext()->getReducedType(sig); |
207 | 208 |
|
208 | 209 | CanAnyFunctionType completionHandlerOrigTy = [&]() {
|
209 | 210 | auto completionHandlerOrigTy =
|
@@ -236,18 +237,17 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction(
|
236 | 237 | // block buffer. The block storage holds the continuation we feed the
|
237 | 238 | // result values into.
|
238 | 239 | SmallVector<SILParameterInfo, 4> implArgs;
|
239 |
| - auto blockStorageTy = SILBlockStorageType::get(continuationTy); |
240 |
| - implArgs.push_back(SILParameterInfo(blockStorageTy, |
241 |
| - ParameterConvention::Indirect_InoutAliasable)); |
242 |
| - |
| 240 | + implArgs.push_back(SILParameterInfo( |
| 241 | + blockStorageType, ParameterConvention::Indirect_InoutAliasable)); |
| 242 | + |
243 | 243 | std::copy(blockType->getParameters().begin(),
|
244 | 244 | blockType->getParameters().end(),
|
245 | 245 | std::back_inserter(implArgs));
|
246 | 246 |
|
247 | 247 | auto newClangTy = prependParameterType(
|
248 | 248 | getASTContext(),
|
249 | 249 | blockType->getClangTypeInfo().getType(),
|
250 |
| - getASTContext().getClangTypeForIRGen(blockStorageTy)); |
| 250 | + getASTContext().getClangTypeForIRGen(blockStorageType)); |
251 | 251 |
|
252 | 252 | auto implTy = SILFunctionType::get(
|
253 | 253 | sig,
|
@@ -384,7 +384,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction(
|
384 | 384 | errorScope.pop();
|
385 | 385 | SGF.B.createBranch(loc, returnBB);
|
386 | 386 | SGF.B.emitBlock(noneErrorBB);
|
387 |
| - } else if (foreignError) { |
| 387 | + } else if (auto foreignError = calleeInfo.foreign.error) { |
388 | 388 | resumeIntrinsic = getResumeUnsafeThrowingContinuation();
|
389 | 389 | } else {
|
390 | 390 | resumeIntrinsic = getResumeUnsafeContinuation();
|
|
0 commit comments