@@ -4878,12 +4878,30 @@ getIsolationFromWitnessedRequirements(ValueDecl *value) {
48784878// / are directly specified on the type.
48794879static std::optional<ActorIsolation>
48804880getIsolationFromConformances (NominalTypeDecl *nominal) {
4881+ auto &ctx = nominal->getASTContext ();
4882+
48814883 if (isa<ProtocolDecl>(nominal))
48824884 return std::nullopt ;
48834885
48844886 std::optional<ActorIsolation> foundIsolation;
4885- for (auto proto :
4886- nominal->getLocalProtocols (ConformanceLookupKind::NonStructural)) {
4887+ for (auto conformance :
4888+ nominal->getLocalConformances (ConformanceLookupKind::NonStructural)) {
4889+
4890+ // Don't include inherited conformances. If a conformance is inherited
4891+ // from a superclass, the isolation of the subclass should be inferred
4892+ // from the superclass, which is done directly in ActorIsolationRequest.
4893+ // If the superclass has opted out of global actor inference, such as
4894+ // by conforming to the protocol in an extension, then the subclass should
4895+ // not infer isolation from the protocol.
4896+ //
4897+ // Gate this change behind an upcoming feature flag; isolation inference
4898+ // changes can break source in language modes < 6.
4899+ if (conformance->getKind () == ProtocolConformanceKind::Inherited &&
4900+ ctx.LangOpts .hasFeature (Feature::GlobalActorIsolatedTypesUsability)) {
4901+ continue ;
4902+ }
4903+
4904+ auto *proto = conformance->getProtocol ();
48874905 switch (auto protoIsolation = getActorIsolation (proto)) {
48884906 case ActorIsolation::ActorInstance:
48894907 case ActorIsolation::Unspecified:
0 commit comments