@@ -1038,12 +1038,13 @@ class TransferNonTransferrableDiagnosticInferrer {
10381038 }
10391039
10401040 static UseDiagnosticInfo
1041- forFunctionArgumentClosure (ApplyIsolationCrossing isolation) {
1042- return {UseDiagnosticInfoKind::FunctionArgumentClosure, isolation};
1041+ forFunctionArgumentClosure (ApplyIsolationCrossing isolation, Type inferredType ) {
1042+ return {UseDiagnosticInfoKind::FunctionArgumentClosure, isolation, inferredType };
10431043 }
10441044
1045- static UseDiagnosticInfo forFunctionArgumentApplyStronglyTransferred () {
1046- return {UseDiagnosticInfoKind::FunctionArgumentApplyStronglyTransferred};
1045+ static UseDiagnosticInfo forFunctionArgumentApplyStronglyTransferred (Type inferredType) {
1046+ return {UseDiagnosticInfoKind::FunctionArgumentApplyStronglyTransferred, {},
1047+ inferredType};
10471048 }
10481049
10491050 static UseDiagnosticInfo
@@ -1106,8 +1107,9 @@ bool TransferNonTransferrableDiagnosticInferrer::initForIsolatedPartialApply(
11061107 for (auto &p : foundCapturedIsolationCrossing) {
11071108 if (std::get<1 >(p) == opIndex) {
11081109 loc = std::get<0 >(p).getLoc ();
1110+ Type type = std::get<0 >(p).getDecl ()->getInterfaceType ();
11091111 diagnosticInfo =
1110- UseDiagnosticInfo::forFunctionArgumentClosure (std::get<2 >(p));
1112+ UseDiagnosticInfo::forFunctionArgumentClosure (std::get<2 >(p), type );
11111113 return true ;
11121114 }
11131115 }
@@ -1155,8 +1157,14 @@ bool TransferNonTransferrableDiagnosticInferrer::run() {
11551157 if (auto fas = FullApplySite::isa (op->getUser ())) {
11561158 if (fas.getArgumentParameterInfo (*op).hasOption (
11571159 SILParameterInfo::Transferring)) {
1160+ Type type = op->get ()->getType ().getASTType ();
1161+ if (auto *inferredArgExpr =
1162+ inferArgumentExprFromApplyExpr (sourceApply, fas, op)) {
1163+ type = inferredArgExpr->findOriginalType ();
1164+ }
1165+
11581166 diagnosticInfo =
1159- UseDiagnosticInfo::forFunctionArgumentApplyStronglyTransferred ();
1167+ UseDiagnosticInfo::forFunctionArgumentApplyStronglyTransferred (type );
11601168 return true ;
11611169 }
11621170 }
@@ -1262,7 +1270,7 @@ void TransferNonSendableImpl::emitTransferredNonTransferrableDiagnostics() {
12621270 }
12631271 case UseDiagnosticInfoKind::FunctionArgumentClosure: {
12641272 diagnoseError (astContext, loc, diag::regionbasedisolation_arg_transferred,
1265- op-> get ()-> getType (). getASTType (),
1273+ diagnosticInfo. getType (),
12661274 diagnosticInfo.getIsolationCrossing ().getCalleeIsolation ())
12671275 .highlight (op->getUser ()->getLoc ().getSourceRange ());
12681276 // Only emit the note if our value is different from the function
@@ -1283,7 +1291,7 @@ void TransferNonSendableImpl::emitTransferredNonTransferrableDiagnostics() {
12831291 diagnoseError (
12841292 astContext, loc,
12851293 diag::regionbasedisolation_arg_passed_to_strongly_transferred_param,
1286- op-> get ()-> getType (). getASTType ())
1294+ diagnosticInfo. getType ())
12871295 .highlight (op->getUser ()->getLoc ().getSourceRange ());
12881296 break ;
12891297 }
0 commit comments