@@ -657,7 +657,7 @@ class UseAfterTransferDiagnosticInferrer {
657657 SILLocation baseLoc = SILLocation::invalid();
658658 Type baseInferredType;
659659
660- struct Walker ;
660+ struct AutoClosureWalker ;
661661
662662public:
663663 UseAfterTransferDiagnosticInferrer (
@@ -750,14 +750,19 @@ void UseAfterTransferDiagnosticInferrer::initForApply(Operand *op,
750750 isolationCrossing);
751751}
752752
753- struct UseAfterTransferDiagnosticInferrer ::Walker : ASTWalker {
753+ // / This walker visits an AutoClosureExpr and looks for uses of a specific
754+ // / captured value. We want to error on the uses in the autoclosure.
755+ struct UseAfterTransferDiagnosticInferrer ::AutoClosureWalker : ASTWalker {
754756 UseAfterTransferDiagnosticInferrer &foundTypeInfo;
755757 ValueDecl *targetDecl;
758+ SILIsolationInfo targetDeclIsolationInfo;
756759 SmallPtrSet<Expr *, 8 > visitedCallExprDeclRefExprs;
757760
758- Walker (UseAfterTransferDiagnosticInferrer &foundTypeInfo,
759- ValueDecl *targetDecl)
760- : foundTypeInfo(foundTypeInfo), targetDecl(targetDecl) {}
761+ AutoClosureWalker (UseAfterTransferDiagnosticInferrer &foundTypeInfo,
762+ ValueDecl *targetDecl,
763+ SILIsolationInfo targetDeclIsolationInfo)
764+ : foundTypeInfo(foundTypeInfo), targetDecl(targetDecl),
765+ targetDeclIsolationInfo (targetDeclIsolationInfo) {}
761766
762767 Expr *lookThroughExpr (Expr *expr) {
763768 while (true ) {
@@ -810,9 +815,9 @@ struct UseAfterTransferDiagnosticInferrer::Walker : ASTWalker {
810815 if (declRef->getDecl () == targetDecl) {
811816 // Found our target!
812817 visitedCallExprDeclRefExprs.insert (declRef);
813- foundTypeInfo.diagnosticEmitter .emitTypedIsolationCrossing (
814- foundTypeInfo.baseLoc , declRef-> findOriginalType (),
815- *isolationCrossing);
818+ foundTypeInfo.diagnosticEmitter .emitNamedIsolationCrossingError (
819+ foundTypeInfo.baseLoc , targetDecl-> getBaseIdentifier (),
820+ targetDeclIsolationInfo, *isolationCrossing);
816821 return Action::Continue (expr);
817822 }
818823 }
@@ -890,7 +895,7 @@ void UseAfterTransferDiagnosticInferrer::infer() {
890895 auto captureInfo =
891896 autoClosureExpr->getCaptureInfo ().getCaptures ()[captureIndex];
892897 auto *captureDecl = captureInfo.getDecl ();
893- Walker walker (*this , captureDecl);
898+ AutoClosureWalker walker (*this , captureDecl, transferOp-> getIsolationInfo () );
894899 autoClosureExpr->walk (walker);
895900}
896901
0 commit comments