@@ -4878,12 +4878,30 @@ getIsolationFromWitnessedRequirements(ValueDecl *value) {
4878
4878
// / are directly specified on the type.
4879
4879
static std::optional<ActorIsolation>
4880
4880
getIsolationFromConformances (NominalTypeDecl *nominal) {
4881
+ auto &ctx = nominal->getASTContext ();
4882
+
4881
4883
if (isa<ProtocolDecl>(nominal))
4882
4884
return std::nullopt;
4883
4885
4884
4886
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 ();
4887
4905
switch (auto protoIsolation = getActorIsolation (proto)) {
4888
4906
case ActorIsolation::ActorInstance:
4889
4907
case ActorIsolation::Unspecified:
0 commit comments