@@ -3758,6 +3758,14 @@ namespace {
3758
3758
if (!unsatisfiedIsolation)
3759
3759
return false ;
3760
3760
3761
+ // Record whether the callee isolation or the context isolation
3762
+ // is preconcurrency, which is used later to downgrade errors to
3763
+ // warnings in minimal checking.
3764
+ bool preconcurrency = getContextIsolation ().preconcurrency () ||
3765
+ (calleeDecl && getActorIsolation (calleeDecl).preconcurrency ());
3766
+ unsatisfiedIsolation =
3767
+ unsatisfiedIsolation->withPreconcurrency (preconcurrency);
3768
+
3761
3769
bool onlyArgsCrossIsolation = callOptions.contains (
3762
3770
ActorReferenceResult::Flags::OnlyArgsCrossIsolation);
3763
3771
if (!onlyArgsCrossIsolation &&
@@ -3775,63 +3783,41 @@ namespace {
3775
3783
// If we need to mark the call as implicitly asynchronous, make sure
3776
3784
// we're in an asynchronous context.
3777
3785
if (requiresAsync && !getDeclContext ()->isAsyncContext ()) {
3786
+ auto diagnostic = calleeDecl ?
3787
+ Diagnostic (
3788
+ /* id*/ diag::actor_isolated_call_decl,
3789
+ /* args*/ *unsatisfiedIsolation, calleeDecl, getContextIsolation ()
3790
+ ) :
3791
+ Diagnostic (
3792
+ /* id*/ diag::actor_isolated_call,
3793
+ /* args*/ *unsatisfiedIsolation, getContextIsolation ()
3794
+ );
3778
3795
3779
3796
if (ctx.LangOpts .hasFeature (Feature::GroupActorErrors)) {
3780
-
3781
- IsolationError mismatch ([calleeDecl, apply, unsatisfiedIsolation, getContextIsolation]() {
3782
- if (calleeDecl) {
3783
- auto preconcurrency = getContextIsolation ().preconcurrency () ||
3784
- getActorIsolation (calleeDecl).preconcurrency ();
3785
-
3786
- return IsolationError (
3787
- apply->getLoc (),
3788
- preconcurrency,
3789
- Diagnostic (diag::actor_isolated_call_decl,
3790
- *unsatisfiedIsolation,
3791
- calleeDecl,
3792
- getContextIsolation ()));
3793
- } else {
3794
- return IsolationError (
3795
- apply->getLoc (),
3796
- getContextIsolation ().preconcurrency (),
3797
- Diagnostic (diag::actor_isolated_call,
3798
- *unsatisfiedIsolation,
3799
- getContextIsolation ()));
3800
- }
3801
- }());
3802
-
3803
- auto iter = applyErrors.find (std::make_pair (*unsatisfiedIsolation, getContextIsolation ()));
3804
- if (iter != applyErrors.end ()){
3805
- iter->second .push_back ((mismatch));
3806
- } else {
3807
- DiagnosticList list;
3808
- list.push_back ((mismatch));
3809
- auto keyPair = std::make_pair (*unsatisfiedIsolation, getContextIsolation ());
3810
- applyErrors.insert (std::make_pair (keyPair, list));
3797
+ IsolationError mismatch (apply->getLoc (), preconcurrency, diagnostic);
3798
+ auto key = std::make_pair (
3799
+ unsatisfiedIsolation->withPreconcurrency (false ),
3800
+ getContextIsolation ());
3801
+ if (applyErrors.find (key) == applyErrors.end ()) {
3802
+ applyErrors.insert (std::make_pair (key, DiagnosticList ()));
3811
3803
}
3804
+
3805
+ applyErrors[key].push_back (mismatch);
3812
3806
} else {
3807
+ ctx.Diags .diagnose (
3808
+ apply->getLoc (),
3809
+ diagnostic.getID (),
3810
+ diagnostic.getArgs ())
3811
+ .warnUntilSwiftVersionIf (preconcurrency, 6 );
3812
+
3813
3813
if (calleeDecl) {
3814
3814
auto calleeIsolation = getInferredActorIsolation (calleeDecl);
3815
- auto preconcurrency = getContextIsolation ().preconcurrency () ||
3816
- calleeIsolation.preconcurrency ();
3817
-
3818
- ctx.Diags .diagnose (
3819
- apply->getLoc (), diag::actor_isolated_call_decl,
3820
- *unsatisfiedIsolation,
3821
- calleeDecl,
3822
- getContextIsolation ())
3823
- .warnUntilSwiftVersionIf (preconcurrency, 6 );
3824
3815
calleeDecl->diagnose (diag::actor_isolated_sync_func, calleeDecl);
3825
3816
if (auto source = calleeIsolation.source .isInferred ()) {
3826
3817
calleeDecl->diagnose (diag::actor_isolation_source,
3827
3818
calleeIsolation.isolation ,
3828
3819
calleeIsolation.source );
3829
3820
}
3830
- } else {
3831
- ctx.Diags .diagnose (
3832
- apply->getLoc (), diag::actor_isolated_call, *unsatisfiedIsolation,
3833
- getContextIsolation ())
3834
- .warnUntilSwiftVersionIf (getContextIsolation ().preconcurrency (), 6 );
3835
3821
}
3836
3822
3837
3823
if (unsatisfiedIsolation->isGlobalActor ()) {
@@ -5962,10 +5948,12 @@ DefaultInitializerIsolation::evaluate(Evaluator &evaluator,
5962
5948
auto requiredIsolation = checker.computeRequiredIsolation (initExpr);
5963
5949
if (requiredIsolation.isActorIsolated ()) {
5964
5950
if (enclosingIsolation != requiredIsolation) {
5951
+ bool preconcurrency =
5952
+ !isa<ParamDecl>(var) || requiredIsolation.preconcurrency ();
5965
5953
var->diagnose (
5966
5954
diag::isolated_default_argument_context,
5967
5955
requiredIsolation, enclosingIsolation)
5968
- .warnUntilSwiftVersionIf (!isa<ParamDecl>(var) , 6 );
5956
+ .warnUntilSwiftVersionIf (preconcurrency , 6 );
5969
5957
return ActorIsolation::forUnspecified ();
5970
5958
}
5971
5959
}
0 commit comments