@@ -3921,38 +3921,61 @@ namespace {
39213921 bool preconcurrencyContext =
39223922 result.options .contains (ActorReferenceResult::Flags::Preconcurrency);
39233923
3924- if (ctx.LangOpts .hasFeature (Feature::GroupActorErrors)) {
3925- IsolationError mismatch = IsolationError (loc, Diagnostic (diag::actor_isolated_non_self_reference,
3926- decl,
3927- useKind,
3928- refKind + 1 , refGlobalActor,
3929- result.isolation ));
3930-
3931- auto iter = refErrors.find (std::make_pair (refKind,result.isolation ));
3932- if (iter != refErrors.end ()){
3933- iter->second .push_back (mismatch);
3934- } else {
3935- DiagnosticList list;
3936- list.push_back (mismatch);
3937- auto keyPair = std::make_pair (refKind,result.isolation );
3938- refErrors.insert (std::make_pair (keyPair, list));
3924+ Type derivedConformanceType;
3925+ DeclName requirementName;
3926+ if (loc.isInvalid ()) {
3927+ auto *decl = getDeclContext ()->getAsDecl ();
3928+ if (decl && decl->isImplicit ()) {
3929+ auto *parentDC = decl->getDeclContext ();
3930+ loc = parentDC->getAsDecl ()->getLoc ();
3931+
3932+ if (auto *implements = decl->getAttrs ().getAttribute <ImplementsAttr>()) {
3933+ derivedConformanceType =
3934+ implements->getProtocol (parentDC)->getDeclaredInterfaceType ();
3935+ requirementName = implements->getMemberName ();
39393936 }
3937+ }
3938+ }
3939+
3940+ if (ctx.LangOpts .hasFeature (Feature::GroupActorErrors)) {
3941+ IsolationError mismatch = IsolationError (loc,
3942+ Diagnostic (diag::actor_isolated_non_self_reference,
3943+ decl, useKind, refKind + 1 , refGlobalActor,
3944+ result.isolation ));
3945+
3946+ auto iter = refErrors.find (std::make_pair (refKind,result.isolation ));
3947+ if (iter != refErrors.end ()) {
3948+ iter->second .push_back (mismatch);
39403949 } else {
3941- ctx.Diags .diagnose (
3942- loc, diag::actor_isolated_non_self_reference,
3943- decl,
3944- useKind,
3945- refKind + 1 , refGlobalActor,
3946- result.isolation )
3947- .warnUntilSwiftVersionIf (preconcurrencyContext, 6 );
3948-
3949- noteIsolatedActorMember (decl, context);
3950- if (result.isolation .isGlobalActor ()) {
3951- missingGlobalActorOnContext (
3952- const_cast <DeclContext *>(getDeclContext ()),
3953- result.isolation .getGlobalActor (), DiagnosticBehavior::Note);
3954- }
3950+ DiagnosticList list;
3951+ list.push_back (mismatch);
3952+ auto keyPair = std::make_pair (refKind,result.isolation );
3953+ refErrors.insert (std::make_pair (keyPair, list));
39553954 }
3955+ } else {
3956+ ctx.Diags .diagnose (
3957+ loc, diag::actor_isolated_non_self_reference,
3958+ decl, useKind,
3959+ refKind + 1 , refGlobalActor,
3960+ result.isolation )
3961+ .warnUntilSwiftVersionIf (preconcurrencyContext, 6 );
3962+
3963+ if (derivedConformanceType) {
3964+ auto *decl = dyn_cast<ValueDecl>(getDeclContext ()->getAsDecl ());
3965+ ctx.Diags .diagnose (loc, diag::in_derived_witness,
3966+ decl->getDescriptiveKind (),
3967+ requirementName,
3968+ derivedConformanceType);
3969+ }
3970+
3971+ noteIsolatedActorMember (decl, context);
3972+ if (result.isolation .isGlobalActor ()) {
3973+ missingGlobalActorOnContext (
3974+ const_cast <DeclContext *>(getDeclContext ()),
3975+ result.isolation .getGlobalActor (), DiagnosticBehavior::Note);
3976+ }
3977+ }
3978+
39563979 return true ;
39573980 }
39583981 }
0 commit comments