Skip to content

Commit 836fcbe

Browse files
committed
Don't infer isolated conformances when the feature isn't enabled
1 parent 6eb7905 commit 836fcbe

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7913,10 +7913,13 @@ ConformanceIsolationRequest::evaluate(Evaluator &evaluator, ProtocolConformance
79137913
return ActorIsolation::forGlobalActor(globalActorType);
79147914
}
79157915

7916-
// In a context where we are inferring @MainActor, if the conforming type
7917-
// is on the main actor, then the conformance is, too.
79187916
auto dc = rootNormal->getDeclContext();
79197917
ASTContext &ctx = dc->getASTContext();
7918+
if (!ctx.LangOpts.hasFeature(Feature::IsolatedConformances))
7919+
return ActorIsolation::forNonisolated(false);
7920+
7921+
// In a context where we are inferring @MainActor, if the conforming type
7922+
// is on the main actor, then the conformance is, too.
79207923
auto nominal = dc->getSelfNominalTypeDecl();
79217924
if (ctx.LangOpts.hasFeature(Feature::UnspecifiedMeansMainActorIsolated) &&
79227925
nominal) {

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3574,12 +3574,12 @@ ConformanceChecker::checkActorIsolation(ValueDecl *requirement,
35743574
// Another way to address the issue is to mark the conformance as
35753575
// isolated to the global actor or "@preconcurrency".
35763576
if (Conformance->getSourceKind() == ConformanceEntryKind::Explicit &&
3577-
!Conformance->getIsolation().isGlobalActor() &&
3577+
!Conformance->isIsolated() &&
35783578
!Conformance->isPreconcurrency() &&
35793579
!suggestedPreconcurrencyOrIsolated &&
3580-
!requirementIsolation.isActorIsolated() &&
3581-
refResult.isolation.isGlobalActor()) {
3582-
if (Context.LangOpts.hasFeature(Feature::IsolatedConformances)) {
3580+
!requirementIsolation.isActorIsolated()) {
3581+
if (Context.LangOpts.hasFeature(Feature::IsolatedConformances) &&
3582+
refResult.isolation.isGlobalActor()) {
35833583
std::string globalActorStr = "@" +
35843584
refResult.isolation.getGlobalActor().getString();
35853585
Context.Diags.diagnose(Conformance->getProtocolNameLoc(),

0 commit comments

Comments
 (0)