Skip to content

Commit 13f1bea

Browse files
authored
Merge pull request #80209 from DougGregor/infer-isolated-conformances
Implement experimental feature InferIsolatedConformances
2 parents ebbec50 + 0831949 commit 13f1bea

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

include/swift/Basic/Features.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CustomAvailability, true)
494494
/// Be strict about the Sendable conformance of metatypes.
495495
EXPERIMENTAL_FEATURE(StrictSendableMetatypes, true)
496496

497-
498497
/// Allow public enumerations to be extensible by default
499498
/// regardless of whether the module they are declared in
500499
/// is resilient or not.
@@ -503,6 +502,9 @@ EXPERIMENTAL_FEATURE(ExtensibleEnums, true)
503502
/// Allow isolated conformances.
504503
EXPERIMENTAL_FEATURE(IsolatedConformances, true)
505504

505+
/// Infer conformance isolation on global-actor-conforming types.
506+
EXPERIMENTAL_FEATURE(InferIsolatedConformances, true)
507+
506508
/// Allow SwiftSettings
507509
EXPERIMENTAL_FEATURE(SwiftSettings, false)
508510

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ UNINTERESTING_FEATURE(ReinitializeConsumeInMultiBlockDefer)
332332
UNINTERESTING_FEATURE(SE427NoInferenceOnExtension)
333333
UNINTERESTING_FEATURE(TrailingComma)
334334
UNINTERESTING_FEATURE(RawIdentifiers)
335+
UNINTERESTING_FEATURE(InferIsolatedConformances)
335336

336337
static ABIAttr *getABIAttr(Decl *decl) {
337338
if (auto pbd = dyn_cast<PatternBindingDecl>(decl))

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,9 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
969969
if (Args.hasArg(OPT_strict_memory_safety))
970970
Opts.enableFeature(Feature::StrictMemorySafety);
971971

972+
if (Opts.hasFeature(Feature::UnspecifiedMeansMainActorIsolated))
973+
Opts.enableFeature(Feature::InferIsolatedConformances);
974+
972975
return HadError;
973976
}
974977

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7934,15 +7934,14 @@ ConformanceIsolationRequest::evaluate(Evaluator &evaluator, ProtocolConformance
79347934
if (getActorIsolation(rootNormal->getProtocol()).isActorIsolated())
79357935
return ActorIsolation::forNonisolated(false);
79367936

7937-
// In a context where we are inferring @MainActor, if the conforming type
7938-
// is on the main actor, then the conformance is, too.
7937+
// If we are inferring isolated conformances and the conforming type is
7938+
// isolated to a global actor,
79397939
auto nominal = dc->getSelfNominalTypeDecl();
7940-
if (ctx.LangOpts.hasFeature(Feature::UnspecifiedMeansMainActorIsolated) &&
7940+
if (ctx.LangOpts.hasFeature(Feature::InferIsolatedConformances) &&
79417941
nominal) {
79427942
auto nominalIsolation = getActorIsolation(nominal);
7943-
if (nominalIsolation.isMainActor()) {
7943+
if (nominalIsolation.isGlobalActor())
79447944
return nominalIsolation;
7945-
}
79467945
}
79477946

79487947
return ActorIsolation::forNonisolated(false);

0 commit comments

Comments
 (0)