@@ -102,7 +102,7 @@ swift::Witness RequirementMatch::getWitness(ASTContext &ctx) const {
102102 auto syntheticEnv = ReqEnv->getSyntheticEnvironment ();
103103 return swift::Witness (this ->Witness , WitnessSubstitutions,
104104 syntheticEnv, ReqEnv->getRequirementToSyntheticMap (),
105- DerivativeGenSig);
105+ DerivativeGenSig, None );
106106}
107107
108108AssociatedTypeDecl *
@@ -2953,7 +2953,7 @@ static bool hasExplicitGlobalActorAttr(ValueDecl *decl) {
29532953 return !globalActorAttr->first ->isImplicit ();
29542954}
29552955
2956- bool ConformanceChecker::checkActorIsolation (
2956+ Optional<ActorIsolation> ConformanceChecker::checkActorIsolation (
29572957 ValueDecl *requirement, ValueDecl *witness) {
29582958 // / Retrieve a concrete witness for Sendable checking.
29592959 auto getConcreteWitness = [&] {
@@ -2993,12 +2993,12 @@ bool ConformanceChecker::checkActorIsolation(
29932993 }
29942994
29952995 // Otherwise, we're done.
2996- return false ;
2996+ return None ;
29972997
29982998 case ActorReferenceResult::ExitsActorToNonisolated:
29992999 diagnoseNonSendableTypesInReference (
30003000 getConcreteWitness (), DC, loc, SendableCheckReason::Conformance);
3001- return false ;
3001+ return None ;
30023002
30033003 case ActorReferenceResult::EntersActor:
30043004 // Handled below.
@@ -3077,12 +3077,16 @@ bool ConformanceChecker::checkActorIsolation(
30773077 // that is explicitly marked nonisolated.
30783078 if (isa<ConstructorDecl>(witness) &&
30793079 witness->getAttrs ().hasAttribute <NonisolatedAttr>())
3080- return false ;
3080+ return None ;
30813081
30823082 diagnoseNonSendableTypesInReference (
30833083 getConcreteWitness (), DC, loc, SendableCheckReason::Conformance);
30843084
3085- return false ;
3085+ if (refResult.isolation .isActorIsolated () && isAsyncDecl (requirement) &&
3086+ !isAsyncDecl (witness))
3087+ return refResult.isolation ;
3088+
3089+ return None;
30863090 }
30873091
30883092 // Limit the behavior of the diagnostic based on context.
@@ -3101,7 +3105,6 @@ bool ConformanceChecker::checkActorIsolation(
31013105
31023106 // Complain that this witness cannot conform to the requirement due to
31033107 // actor isolation.
3104- bool isError = (behavior == DiagnosticBehavior::Unspecified);
31053108 witness->diagnose (diag::actor_isolated_witness,
31063109 isDistributed && !isDistributedDecl (witness),
31073110 refResult.isolation , witness->getDescriptiveKind (),
@@ -3189,7 +3192,7 @@ bool ConformanceChecker::checkActorIsolation(
31893192 requirement->diagnose (diag::decl_declared_here, requirement->getName ());
31903193 }
31913194
3192- return isError ;
3195+ return None ;
31933196}
31943197
31953198bool ConformanceChecker::checkObjCTypeErasedGenerics (
@@ -5092,8 +5095,13 @@ void ConformanceChecker::resolveValueWitnesses() {
50925095
50935096 auto &C = witness->getASTContext ();
50945097
5095- if (checkActorIsolation (requirement, witness)) {
5096- return ;
5098+ // Check actor isolation. If we need to enter into the actor's
5099+ // isolation within the witness thunk, record that.
5100+ if (auto enteringIsolation = checkActorIsolation (requirement, witness)) {
5101+ Conformance->overrideWitness (
5102+ requirement,
5103+ Conformance->getWitnessUncached (requirement)
5104+ .withEnterIsolation (*enteringIsolation));
50975105 }
50985106
50995107 // Objective-C checking for @objc requirements.
0 commit comments