Skip to content

Commit a1ea822

Browse files
committed
Don't actually warn about about the property wrapper isolation in Swift 5.
In many cases, the inferrence was unexpected and undesired. We shouldn't warn the user about something that is reasonably likely to be correct.
1 parent 982e14b commit a1ea822

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5122,12 +5122,6 @@ ERROR(async_unavailable_decl,none,
51225122
"%0 %1 is unavailable from asynchronous contexts%select{|; %2}2",
51235123
(DescriptiveDeclKind, DeclBaseName, StringRef))
51245124

5125-
WARNING(actor_isolation_inferred_from_property_wrapper,none,
5126-
"%0 is implicitly %1 because it uses %2. This implicit isolation "
5127-
"will no longer happen in Swift 6.",
5128-
(DeclName, ActorIsolation, StringRef))
5129-
5130-
51315125
//------------------------------------------------------------------------------
51325126
// MARK: String Processing
51335127
//------------------------------------------------------------------------------

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,13 +3452,12 @@ static Optional<ActorIsolation> getIsolationFromWrappers(
34523452

34533453
ASTContext &ctx = nominal->getASTContext();
34543454
if (ctx.isSwiftVersionAtLeast(6)) {
3455-
// In Swift 6, we no longer infer isolation of a nominal type based
3456-
// on property wrappers used in its stored properties
3455+
// In Swift 6, we no longer infer isolation of a nominal type
3456+
// based on the property wrappers used in its stored properties
34573457
return None;
34583458
}
34593459

3460-
Optional<std::pair<ActorIsolation, Type>> foundIsolationAndType;
3461-
3460+
Optional<ActorIsolation> foundIsolation;
34623461
for (auto member : nominal->getMembers()) {
34633462
auto var = dyn_cast<VarDecl>(member);
34643463
if (!var || !var->isInstanceMember())
@@ -3483,36 +3482,19 @@ static Optional<ActorIsolation> getIsolationFromWrappers(
34833482

34843483
case ActorIsolation::GlobalActor:
34853484
case ActorIsolation::GlobalActorUnsafe:
3486-
if (!foundIsolationAndType) {
3487-
if (auto propertyWrapperType = var->getAttachedPropertyWrapperType(0)) {
3488-
foundIsolationAndType = { isolation, propertyWrapperType };
3489-
continue;
3490-
}
3485+
if (!foundIsolation) {
3486+
foundIsolation = isolation;
3487+
continue;
34913488
}
34923489

3493-
if (foundIsolationAndType->first != isolation)
3490+
if (*foundIsolation != isolation)
34943491
return None;
34953492

34963493
break;
34973494
}
34983495
}
34993496

3500-
if (foundIsolationAndType) {
3501-
// We are inferring isolation for the type because
3502-
// it contains an actor-isolated property wrapper.
3503-
// Warn that this inferrence will be going away in
3504-
// Swift 6
3505-
const ActorIsolation isolation = foundIsolationAndType->first;
3506-
const Type type = foundIsolationAndType->second;
3507-
3508-
nominal->diagnose(diag::actor_isolation_inferred_from_property_wrapper,
3509-
nominal->getName(), isolation, "'@"+type->getString()+"'")
3510-
.fixItInsert(nominal->getAttributeInsertionLoc(false), "@" + isolation.getGlobalActor().getString());
3511-
return isolation;
3512-
}
3513-
else {
3514-
return None;
3515-
}
3497+
return foundIsolation;
35163498
}
35173499

35183500
namespace {

0 commit comments

Comments
 (0)