@@ -1197,21 +1197,30 @@ bool swift::diagnoseNonSendableTypesInReference(
1197
1197
}
1198
1198
1199
1199
// Check the result type of a function or subscript.
1200
- if (auto func = dyn_cast<FuncDecl>(decl)) {
1201
- if (funcCheckOptions.contains (FunctionCheckKind::Results)) {
1202
- // only check results if funcCheckKind specifies so
1203
- Type resultType = func->getResultInterfaceType ().subst (subs);
1204
- auto diag = getSendableResultDiag (refKind);
1205
- if (diag.ID == diag::non_sendable_result_in_witness.ID &&
1206
- func->hasSendingResult () && !resultType->hasError ()) {
1207
- return false ;
1208
- }
1209
- if (diagnoseNonSendableTypes (
1210
- resultType, fromDC, derivedConformanceType, refLoc,
1211
- diagnoseLoc.isInvalid () ? refLoc : diagnoseLoc, diag, func,
1212
- getActorIsolation ()))
1213
- return true ;
1200
+ if (funcCheckOptions.contains (FunctionCheckKind::Results)) {
1201
+ Type resultType;
1202
+ bool hasSendingResult;
1203
+ if (auto func = dyn_cast<FuncDecl>(decl)) {
1204
+ resultType = func->getResultInterfaceType ().subst (subs);
1205
+ hasSendingResult = func->hasSendingResult ();
1206
+ decl = func;
1207
+ } else if (auto subscript = dyn_cast<SubscriptDecl>(decl)) {
1208
+ resultType = subscript->getElementInterfaceType ().subst (subs);
1209
+ hasSendingResult = isa<SendingTypeRepr>(subscript->getResultTypeRepr ());
1214
1210
}
1211
+ if (!resultType) {
1212
+ return false ;
1213
+ }
1214
+ auto diag = getSendableResultDiag (refKind);
1215
+ if (diag.ID == diag::non_sendable_result_in_witness.ID &&
1216
+ hasSendingResult && !resultType->hasError ()) {
1217
+ return false ;
1218
+ }
1219
+ if (diagnoseNonSendableTypes (
1220
+ resultType, fromDC, derivedConformanceType, refLoc,
1221
+ diagnoseLoc.isInvalid () ? refLoc : diagnoseLoc, diag, decl,
1222
+ getActorIsolation ()))
1223
+ return true ;
1215
1224
}
1216
1225
1217
1226
return false ;
0 commit comments