@@ -891,7 +891,7 @@ bool UseAfterTransferDiagnosticInferrer::initForIsolatedPartialApply(
891891 if (foundCapturedIsolationCrossing.empty ())
892892 return false ;
893893
894- unsigned opIndex = ApplySite (op->getUser ()).getAppliedArgIndex (*op);
894+ unsigned opIndex = ApplySite (op->getUser ()).getASTAppliedArgIndex (*op);
895895 bool emittedDiagnostic = false ;
896896 for (auto &p : foundCapturedIsolationCrossing) {
897897 if (std::get<1 >(p) != opIndex)
@@ -1131,7 +1131,7 @@ void UseAfterTransferDiagnosticInferrer::infer() {
11311131
11321132 auto *i = transferOp->getUser ();
11331133 auto pai = ApplySite::isa (i);
1134- unsigned captureIndex = pai.getAppliedArgIndex (*transferOp);
1134+ unsigned captureIndex = pai.getASTAppliedArgIndex (*transferOp);
11351135
11361136 auto &state = transferringOpToStateMap.get (transferOp);
11371137 auto captureInfo =
@@ -1640,11 +1640,7 @@ class SentNeverSendableDiagnosticInferrer {
16401640 for (auto &paiOp : ApplySite (pai).getArgumentOperands ()) {
16411641 if (valueMap.getTrackableValue (paiOp.get ()).getRepresentative () ==
16421642 isolatedValue) {
1643- // isolated_any causes all partial apply parameters to be shifted by 1
1644- // due to the implicit isolated any parameter.
1645- unsigned isIsolatedAny = pai->getFunctionType ()->getIsolation () ==
1646- SILFunctionTypeIsolation::Erased;
1647- return ApplySite (pai).getAppliedArgIndex (paiOp) - isIsolatedAny;
1643+ return ApplySite (pai).getASTAppliedArgIndex (paiOp);
16481644 }
16491645 }
16501646
@@ -1728,7 +1724,10 @@ bool SentNeverSendableDiagnosticInferrer::initForIsolatedPartialApply(
17281724 if (foundCapturedIsolationCrossing.empty ())
17291725 return false ;
17301726
1731- unsigned opIndex = ApplySite (op->getUser ()).getAppliedArgIndex (*op);
1727+ // We use getASTAppliedArgIndex instead of getAppliedArgIndex to ensure that
1728+ // we ignore for our indexing purposes any implicit initial parameters like
1729+ // isolated(any).
1730+ unsigned opIndex = ApplySite (op->getUser ()).getASTAppliedArgIndex (*op);
17321731 for (auto &p : foundCapturedIsolationCrossing) {
17331732 if (std::get<1 >(p) == opIndex) {
17341733 auto loc = RegularLocation (std::get<0 >(p).getLoc ());
@@ -1944,7 +1943,7 @@ bool SentNeverSendableDiagnosticInferrer::run() {
19441943 if (autoClosureExpr->getThunkKind () == AutoClosureExpr::Kind::AsyncLet) {
19451944 auto *i = op->getUser ();
19461945 auto pai = ApplySite::isa (i);
1947- unsigned captureIndex = pai.getAppliedArgIndex (*op);
1946+ unsigned captureIndex = pai.getASTAppliedArgIndex (*op);
19481947 auto captureInfo =
19491948 autoClosureExpr->getCaptureInfo ().getCaptures ()[captureIndex];
19501949 auto loc = RegularLocation (captureInfo.getLoc (), false /* implicit*/ );
0 commit comments