@@ -657,7 +657,7 @@ class UseAfterTransferDiagnosticInferrer {
657
657
SILLocation baseLoc = SILLocation::invalid();
658
658
Type baseInferredType;
659
659
660
- struct Walker ;
660
+ struct AutoClosureWalker ;
661
661
662
662
public:
663
663
UseAfterTransferDiagnosticInferrer (
@@ -750,14 +750,19 @@ void UseAfterTransferDiagnosticInferrer::initForApply(Operand *op,
750
750
isolationCrossing);
751
751
}
752
752
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 {
754
756
UseAfterTransferDiagnosticInferrer &foundTypeInfo;
755
757
ValueDecl *targetDecl;
758
+ SILIsolationInfo targetDeclIsolationInfo;
756
759
SmallPtrSet<Expr *, 8 > visitedCallExprDeclRefExprs;
757
760
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) {}
761
766
762
767
Expr *lookThroughExpr (Expr *expr) {
763
768
while (true ) {
@@ -810,9 +815,9 @@ struct UseAfterTransferDiagnosticInferrer::Walker : ASTWalker {
810
815
if (declRef->getDecl () == targetDecl) {
811
816
// Found our target!
812
817
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);
816
821
return Action::Continue (expr);
817
822
}
818
823
}
@@ -890,7 +895,7 @@ void UseAfterTransferDiagnosticInferrer::infer() {
890
895
auto captureInfo =
891
896
autoClosureExpr->getCaptureInfo ().getCaptures ()[captureIndex];
892
897
auto *captureDecl = captureInfo.getDecl ();
893
- Walker walker (*this , captureDecl);
898
+ AutoClosureWalker walker (*this , captureDecl, transferOp-> getIsolationInfo () );
894
899
autoClosureExpr->walk (walker);
895
900
}
896
901
0 commit comments