@@ -1038,12 +1038,13 @@ class TransferNonTransferrableDiagnosticInferrer {
1038
1038
}
1039
1039
1040
1040
static UseDiagnosticInfo
1041
- forFunctionArgumentClosure(ApplyIsolationCrossing isolation) {
1042
- return {UseDiagnosticInfoKind::FunctionArgumentClosure, isolation};
1041
+ forFunctionArgumentClosure(ApplyIsolationCrossing isolation, Type inferredType ) {
1042
+ return {UseDiagnosticInfoKind::FunctionArgumentClosure, isolation, inferredType };
1043
1043
}
1044
1044
1045
- static UseDiagnosticInfo forFunctionArgumentApplyStronglyTransferred() {
1046
- return {UseDiagnosticInfoKind::FunctionArgumentApplyStronglyTransferred};
1045
+ static UseDiagnosticInfo forFunctionArgumentApplyStronglyTransferred(Type inferredType) {
1046
+ return {UseDiagnosticInfoKind::FunctionArgumentApplyStronglyTransferred, {},
1047
+ inferredType};
1047
1048
}
1048
1049
1049
1050
static UseDiagnosticInfo
@@ -1106,8 +1107,9 @@ bool TransferNonTransferrableDiagnosticInferrer::initForIsolatedPartialApply(
1106
1107
for (auto &p : foundCapturedIsolationCrossing) {
1107
1108
if (std::get<1>(p) == opIndex) {
1108
1109
loc = std::get<0>(p).getLoc();
1110
+ Type type = std::get<0>(p).getDecl()->getInterfaceType();
1109
1111
diagnosticInfo =
1110
- UseDiagnosticInfo::forFunctionArgumentClosure(std::get<2>(p));
1112
+ UseDiagnosticInfo::forFunctionArgumentClosure(std::get<2>(p), type );
1111
1113
return true;
1112
1114
}
1113
1115
}
@@ -1155,8 +1157,14 @@ bool TransferNonTransferrableDiagnosticInferrer::run() {
1155
1157
if (auto fas = FullApplySite::isa(op->getUser())) {
1156
1158
if (fas.getArgumentParameterInfo(*op).hasOption(
1157
1159
SILParameterInfo::Transferring)) {
1160
+ Type type = op->get()->getType().getASTType();
1161
+ if (auto *inferredArgExpr =
1162
+ inferArgumentExprFromApplyExpr(sourceApply, fas, op)) {
1163
+ type = inferredArgExpr->findOriginalType();
1164
+ }
1165
+
1158
1166
diagnosticInfo =
1159
- UseDiagnosticInfo::forFunctionArgumentApplyStronglyTransferred();
1167
+ UseDiagnosticInfo::forFunctionArgumentApplyStronglyTransferred(type );
1160
1168
return true;
1161
1169
}
1162
1170
}
@@ -1262,7 +1270,7 @@ void TransferNonSendableImpl::emitTransferredNonTransferrableDiagnostics() {
1262
1270
}
1263
1271
case UseDiagnosticInfoKind::FunctionArgumentClosure: {
1264
1272
diagnoseError(astContext, loc, diag::regionbasedisolation_arg_transferred,
1265
- op->get()->getType().getASTType (),
1273
+ diagnosticInfo.getType (),
1266
1274
diagnosticInfo.getIsolationCrossing().getCalleeIsolation())
1267
1275
.highlight(op->getUser()->getLoc().getSourceRange());
1268
1276
// Only emit the note if our value is different from the function
@@ -1283,7 +1291,7 @@ void TransferNonSendableImpl::emitTransferredNonTransferrableDiagnostics() {
1283
1291
diagnoseError(
1284
1292
astContext, loc,
1285
1293
diag::regionbasedisolation_arg_passed_to_strongly_transferred_param,
1286
- op->get()->getType().getASTType ())
1294
+ diagnosticInfo.getType ())
1287
1295
.highlight(op->getUser()->getLoc().getSourceRange());
1288
1296
break;
1289
1297
}
0 commit comments