Skip to content

Commit 0831949

Browse files
committed
Implement experimental feature InferIsolatedConformances
Introduce the experimental feature InferIsolatedConformances to align with the upcoming feature proposed in SE-0470. This is a slight generalization of the main-actor-specific inference that was already in place for the default-main-actor mode from SE-0466. Note that, as specified in SE-0470, InferIsolatedConformances is implied by the default-main-actor mode.
1 parent 2ce0493 commit 0831949

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
@@ -496,7 +496,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CustomAvailability, true)
496496
/// Be strict about the Sendable conformance of metatypes.
497497
EXPERIMENTAL_FEATURE(StrictSendableMetatypes, true)
498498

499-
500499
/// Allow public enumerations to be extensible by default
501500
/// regardless of whether the module they are declared in
502501
/// is resilient or not.
@@ -505,6 +504,9 @@ EXPERIMENTAL_FEATURE(ExtensibleEnums, true)
505504
/// Allow isolated conformances.
506505
EXPERIMENTAL_FEATURE(IsolatedConformances, true)
507506

507+
/// Infer conformance isolation on global-actor-conforming types.
508+
EXPERIMENTAL_FEATURE(InferIsolatedConformances, true)
509+
508510
/// Allow SwiftSettings
509511
EXPERIMENTAL_FEATURE(SwiftSettings, false)
510512

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ UNINTERESTING_FEATURE(ReinitializeConsumeInMultiBlockDefer)
331331
UNINTERESTING_FEATURE(SE427NoInferenceOnExtension)
332332
UNINTERESTING_FEATURE(TrailingComma)
333333
UNINTERESTING_FEATURE(RawIdentifiers)
334+
UNINTERESTING_FEATURE(InferIsolatedConformances)
334335

335336
static ABIAttr *getABIAttr(Decl *decl) {
336337
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
@@ -920,6 +920,9 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
920920
if (Args.hasArg(OPT_strict_memory_safety))
921921
Opts.enableFeature(Feature::StrictMemorySafety);
922922

923+
if (Opts.hasFeature(Feature::UnspecifiedMeansMainActorIsolated))
924+
Opts.enableFeature(Feature::InferIsolatedConformances);
925+
923926
return HadError;
924927
}
925928

lib/Sema/TypeCheckConcurrency.cpp

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

7927-
// In a context where we are inferring @MainActor, if the conforming type
7928-
// is on the main actor, then the conformance is, too.
7927+
// If we are inferring isolated conformances and the conforming type is
7928+
// isolated to a global actor,
79297929
auto nominal = dc->getSelfNominalTypeDecl();
7930-
if (ctx.LangOpts.hasFeature(Feature::UnspecifiedMeansMainActorIsolated) &&
7930+
if (ctx.LangOpts.hasFeature(Feature::InferIsolatedConformances) &&
79317931
nominal) {
79327932
auto nominalIsolation = getActorIsolation(nominal);
7933-
if (nominalIsolation.isMainActor()) {
7933+
if (nominalIsolation.isGlobalActor())
79347934
return nominalIsolation;
7935-
}
79367935
}
79377936

79387937
return ActorIsolation::forNonisolated(false);

0 commit comments

Comments
 (0)