@@ -6133,14 +6133,22 @@ void IRGenSILFunction::visitWitnessMethodInst(swift::WitnessMethodInst *i) {
6133
6133
CanType baseTy = i->getLookupType ();
6134
6134
ProtocolConformanceRef conformance = i->getConformance ();
6135
6135
SILDeclRef member = i->getMember ();
6136
+ auto fnType = IGM.getSILTypes ().getConstantFunctionType (
6137
+ IGM.getMaximalTypeExpansionContext (), member);
6136
6138
6137
6139
assert (member.requiresNewWitnessTableEntry ());
6138
6140
6139
6141
if (IGM.isResilient (conformance.getRequirement (),
6140
6142
ResilienceExpansion::Maximal)) {
6141
- auto *fnPtr = IGM.getAddrOfDispatchThunk (member, NotForDefinition);
6142
- auto fnType = IGM.getSILTypes ().getConstantFunctionType (
6143
- IGM.getMaximalTypeExpansionContext (), member);
6143
+ llvm::Constant *fnPtr = IGM.getAddrOfDispatchThunk (member, NotForDefinition);
6144
+
6145
+ if (fnType->isAsync ()) {
6146
+ auto *fnPtrType = fnPtr->getType ();
6147
+ fnPtr = IGM.getAddrOfAsyncFunctionPointer (
6148
+ LinkEntity::forDispatchThunk (member));
6149
+ fnPtr = llvm::ConstantExpr::getBitCast (fnPtr, fnPtrType);
6150
+ }
6151
+
6144
6152
auto sig = IGM.getSignature (fnType);
6145
6153
auto fn = FunctionPointer::forDirect (fnType, fnPtr, sig);
6146
6154
@@ -6340,7 +6348,15 @@ void IRGenSILFunction::visitClassMethodInst(swift::ClassMethodInst *i) {
6340
6348
auto *classDecl = cast<ClassDecl>(method.getDecl ()->getDeclContext ());
6341
6349
if (IGM.hasResilientMetadata (classDecl,
6342
6350
ResilienceExpansion::Maximal)) {
6343
- auto *fnPtr = IGM.getAddrOfDispatchThunk (method, NotForDefinition);
6351
+ llvm::Constant *fnPtr = IGM.getAddrOfDispatchThunk (method, NotForDefinition);
6352
+
6353
+ if (methodType->isAsync ()) {
6354
+ auto *fnPtrType = fnPtr->getType ();
6355
+ fnPtr = IGM.getAddrOfAsyncFunctionPointer (
6356
+ LinkEntity::forDispatchThunk (method));
6357
+ fnPtr = llvm::ConstantExpr::getBitCast (fnPtr, fnPtrType);
6358
+ }
6359
+
6344
6360
auto sig = IGM.getSignature (methodType);
6345
6361
FunctionPointer fn (methodType, fnPtr, sig);
6346
6362
0 commit comments