|
16 | 16 | #include "swift/AST/Expr.h" |
17 | 17 | #include "swift/AST/ActorIsolation.h" |
18 | 18 | #include "swift/AST/DiagnosticsSIL.h" |
| 19 | +#include "swift/Sema/Concurrency.h" |
19 | 20 | #include "swift/SIL/ApplySite.h" |
20 | 21 | #include "swift/SIL/BitDataflow.h" |
21 | 22 | #include "swift/SIL/BasicBlockBits.h" |
@@ -528,31 +529,17 @@ static bool onlyDeinitAccess(RefElementAddrInst *inst) { |
528 | 529 | /// is happening in a deinit that uses flow-isolation. |
529 | 530 | /// \returns true iff a diagnostic was emitted for this reference. |
530 | 531 | static bool diagnoseNonSendableFromDeinit(RefElementAddrInst *inst) { |
531 | | - VarDecl *var = inst->getField(); |
532 | | - Type ty = var->getTypeInContext(); |
533 | | - DeclContext *dc = inst->getFunction()->getDeclContext(); |
| 532 | + auto dc = inst->getFunction()->getDeclContext(); |
534 | 533 |
|
535 | | -// FIXME: we should emit diagnostics in other modes using: |
536 | | -// |
537 | | -// if (!shouldDiagnoseExistingDataRaces(dc)) |
538 | | -// return false; |
539 | | -// |
540 | | -// but until we decide how we want to handle isolated state from deinits, |
541 | | -// we're going to limit the noise to complete mode for now. |
| 534 | + // For historical reasons, only diagnose this issue in strict mode. |
542 | 535 | if (dc->getASTContext().LangOpts.StrictConcurrencyLevel |
543 | | - != StrictConcurrency::Complete) |
544 | | - return false; |
545 | | - |
546 | | - if (ty->isSendableType()) |
| 536 | + != StrictConcurrency::Complete) |
547 | 537 | return false; |
548 | 538 |
|
549 | | - auto &diag = var->getASTContext().Diags; |
550 | | - |
551 | | - diag.diagnose(inst->getLoc().getSourceLoc(), diag::non_sendable_from_deinit, |
552 | | - ty, var->getDescriptiveKind(), var->getName()) |
553 | | - .warnUntilSwiftVersion(6); |
554 | | - |
555 | | - return true; |
| 539 | + return swift::diagnoseNonSendableFromDeinit( |
| 540 | + inst->getLoc().getSourceLoc(), |
| 541 | + inst->getField(), |
| 542 | + dc); |
556 | 543 | } |
557 | 544 |
|
558 | 545 | class OperandWorklist { |
|
0 commit comments