@@ -3909,38 +3909,61 @@ namespace {
39093909 bool preconcurrencyContext =
39103910 result.options .contains (ActorReferenceResult::Flags::Preconcurrency);
39113911
3912- if (ctx.LangOpts .hasFeature (Feature::GroupActorErrors)) {
3913- IsolationError mismatch = IsolationError (loc, Diagnostic (diag::actor_isolated_non_self_reference,
3914- decl,
3915- useKind,
3916- refKind + 1 , refGlobalActor,
3917- result.isolation ));
3918-
3919- auto iter = refErrors.find (std::make_pair (refKind,result.isolation ));
3920- if (iter != refErrors.end ()){
3921- iter->second .push_back (mismatch);
3922- } else {
3923- DiagnosticList list;
3924- list.push_back (mismatch);
3925- auto keyPair = std::make_pair (refKind,result.isolation );
3926- refErrors.insert (std::make_pair (keyPair, list));
3912+ Type derivedConformanceType;
3913+ DeclName requirementName;
3914+ if (loc.isInvalid ()) {
3915+ auto *decl = getDeclContext ()->getAsDecl ();
3916+ if (decl && decl->isImplicit ()) {
3917+ auto *parentDC = decl->getDeclContext ();
3918+ loc = parentDC->getAsDecl ()->getLoc ();
3919+
3920+ if (auto *implements = decl->getAttrs ().getAttribute <ImplementsAttr>()) {
3921+ derivedConformanceType =
3922+ implements->getProtocol (parentDC)->getDeclaredInterfaceType ();
3923+ requirementName = implements->getMemberName ();
39273924 }
3925+ }
3926+ }
3927+
3928+ if (ctx.LangOpts .hasFeature (Feature::GroupActorErrors)) {
3929+ IsolationError mismatch = IsolationError (loc,
3930+ Diagnostic (diag::actor_isolated_non_self_reference,
3931+ decl, useKind, refKind + 1 , refGlobalActor,
3932+ result.isolation ));
3933+
3934+ auto iter = refErrors.find (std::make_pair (refKind,result.isolation ));
3935+ if (iter != refErrors.end ()) {
3936+ iter->second .push_back (mismatch);
39283937 } else {
3929- ctx.Diags .diagnose (
3930- loc, diag::actor_isolated_non_self_reference,
3931- decl,
3932- useKind,
3933- refKind + 1 , refGlobalActor,
3934- result.isolation )
3935- .warnUntilSwiftVersionIf (preconcurrencyContext, 6 );
3936-
3937- noteIsolatedActorMember (decl, context);
3938- if (result.isolation .isGlobalActor ()) {
3939- missingGlobalActorOnContext (
3940- const_cast <DeclContext *>(getDeclContext ()),
3941- result.isolation .getGlobalActor (), DiagnosticBehavior::Note);
3942- }
3938+ DiagnosticList list;
3939+ list.push_back (mismatch);
3940+ auto keyPair = std::make_pair (refKind,result.isolation );
3941+ refErrors.insert (std::make_pair (keyPair, list));
39433942 }
3943+ } else {
3944+ ctx.Diags .diagnose (
3945+ loc, diag::actor_isolated_non_self_reference,
3946+ decl, useKind,
3947+ refKind + 1 , refGlobalActor,
3948+ result.isolation )
3949+ .warnUntilSwiftVersionIf (preconcurrencyContext, 6 );
3950+
3951+ if (derivedConformanceType) {
3952+ auto *decl = dyn_cast<ValueDecl>(getDeclContext ()->getAsDecl ());
3953+ ctx.Diags .diagnose (loc, diag::in_derived_witness,
3954+ decl->getDescriptiveKind (),
3955+ requirementName,
3956+ derivedConformanceType);
3957+ }
3958+
3959+ noteIsolatedActorMember (decl, context);
3960+ if (result.isolation .isGlobalActor ()) {
3961+ missingGlobalActorOnContext (
3962+ const_cast <DeclContext *>(getDeclContext ()),
3963+ result.isolation .getGlobalActor (), DiagnosticBehavior::Note);
3964+ }
3965+ }
3966+
39443967 return true ;
39453968 }
39463969 }
0 commit comments