Skip to content

Commit 0f7a206

Browse files
bjhomerDougGregor
authored andcommitted
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. (cherry picked from commit a1ea822)
1 parent 9aae417 commit 0f7a206

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
@@ -5364,12 +5364,6 @@ ERROR(async_unavailable_decl,none,
53645364
"%0 %1 is unavailable from asynchronous contexts%select{|; %2}2",
53655365
(DescriptiveDeclKind, DeclBaseName, StringRef))
53665366

5367-
WARNING(actor_isolation_inferred_from_property_wrapper,none,
5368-
"%0 is implicitly %1 because it uses %2. This implicit isolation "
5369-
"will no longer happen in Swift 6.",
5370-
(DeclName, ActorIsolation, StringRef))
5371-
5372-
53735367
//------------------------------------------------------------------------------
53745368
// MARK: String Processing
53755369
//------------------------------------------------------------------------------

lib/Sema/TypeCheckConcurrency.cpp

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

36263626
ASTContext &ctx = nominal->getASTContext();
36273627
if (ctx.isSwiftVersionAtLeast(6)) {
3628-
// In Swift 6, we no longer infer isolation of a nominal type based
3629-
// on property wrappers used in its stored properties
3628+
// In Swift 6, we no longer infer isolation of a nominal type
3629+
// based on the property wrappers used in its stored properties
36303630
return None;
36313631
}
36323632

3633-
Optional<std::pair<ActorIsolation, Type>> foundIsolationAndType;
3634-
3633+
Optional<ActorIsolation> foundIsolation;
36353634
for (auto member : nominal->getMembers()) {
36363635
auto var = dyn_cast<VarDecl>(member);
36373636
if (!var || !var->isInstanceMember())
@@ -3656,36 +3655,19 @@ static Optional<ActorIsolation> getIsolationFromWrappers(
36563655

36573656
case ActorIsolation::GlobalActor:
36583657
case ActorIsolation::GlobalActorUnsafe:
3659-
if (!foundIsolationAndType) {
3660-
if (auto propertyWrapperType = var->getAttachedPropertyWrapperType(0)) {
3661-
foundIsolationAndType = { isolation, propertyWrapperType };
3662-
continue;
3663-
}
3658+
if (!foundIsolation) {
3659+
foundIsolation = isolation;
3660+
continue;
36643661
}
36653662

3666-
if (foundIsolationAndType->first != isolation)
3663+
if (*foundIsolation != isolation)
36673664
return None;
36683665

36693666
break;
36703667
}
36713668
}
36723669

3673-
if (foundIsolationAndType) {
3674-
// We are inferring isolation for the type because
3675-
// it contains an actor-isolated property wrapper.
3676-
// Warn that this inferrence will be going away in
3677-
// Swift 6
3678-
const ActorIsolation isolation = foundIsolationAndType->first;
3679-
const Type type = foundIsolationAndType->second;
3680-
3681-
nominal->diagnose(diag::actor_isolation_inferred_from_property_wrapper,
3682-
nominal->getName(), isolation, "'@"+type->getString()+"'")
3683-
.fixItInsert(nominal->getAttributeInsertionLoc(false), "@" + isolation.getGlobalActor().getString());
3684-
return isolation;
3685-
}
3686-
else {
3687-
return None;
3688-
}
3670+
return foundIsolation;
36893671
}
36903672

36913673
namespace {

0 commit comments

Comments
 (0)