Skip to content

Commit 057e696

Browse files
committed
replace NominalTypeDecl::isValueType with a direct struct test
enums don't and will never have stored properties, so just be direct.
1 parent a60da75 commit 057e696

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,14 +3538,6 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
35383538
/// Whether this nominal type qualifies as any actor (plain or distributed).
35393539
bool isAnyActor() const;
35403540

3541-
/// Whether this nominal type corresponds to a language-level value type
3542-
/// (i.e., structs and enums), meaning that a shallow copy is created when
3543-
/// reassigning an instance member of the type. That is in contrast with
3544-
/// reference types like classes and actors, where such mutations are
3545-
/// reflected for all instance holders. A protocol is not considered a
3546-
/// value type, even though their conformers might be a value type.
3547-
bool isValueType() const;
3548-
35493541
/// Return the range of semantics attributes attached to this NominalTypeDecl.
35503542
auto getSemanticsAttrs() const
35513543
-> decltype(getAttrs().getSemanticsAttrs()) {

lib/AST/Decl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,10 +4286,6 @@ bool NominalTypeDecl::isAnyActor() const {
42864286
return isActor() || isDistributedActor();
42874287
}
42884288

4289-
bool NominalTypeDecl::isValueType() const {
4290-
return isa<StructDecl>(this) || isa<EnumDecl>(this);
4291-
}
4292-
42934289
GenericTypeDecl::GenericTypeDecl(DeclKind K, DeclContext *DC,
42944290
Identifier name, SourceLoc nameLoc,
42954291
ArrayRef<InheritedEntry> inherited,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5629,8 +5629,8 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
56295629
return;
56305630
}
56315631

5632-
// 'nonisolated' is redundant for the stored properties of a value type.
5633-
if (nominal->isValueType() && !var->isStatic() &&
5632+
// 'nonisolated' is redundant for the stored properties of a struct.
5633+
if (isa<StructDecl>(nominal) && !var->isStatic() &&
56345634
var->isOrdinaryStoredProperty()) {
56355635
diagnoseAndRemoveAttr(attr, diag::nonisolated_storage_value_type,
56365636
nominal->getDescriptiveKind())

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,10 @@ GlobalActorAttributeRequest::evaluate(
356356
return None;
357357
}
358358

359-
// ... and not if it's the instance storage of a value type
359+
// ... and not if it's the instance storage of a struct
360360
if (!var->isStatic() && var->isOrdinaryStoredProperty()) {
361361
if (auto *nominal = var->getDeclContext()->getSelfNominalTypeDecl()) {
362-
if (nominal->isValueType()) {
362+
if (isa<StructDecl>(nominal)) {
363363

364364
var->diagnose(diag::global_actor_on_storage_of_value_type,
365365
var->getName(), nominal->getDescriptiveKind())
@@ -3626,12 +3626,12 @@ ActorIsolation ActorIsolationRequest::evaluate(
36263626

36273627
case ActorIsolation::GlobalActorUnsafe:
36283628
case ActorIsolation::GlobalActor: {
3629-
// Stored properties of a value type don't need global-actor isolation.
3629+
// Stored properties of a struct don't need global-actor isolation.
36303630
if (auto *var = dyn_cast<VarDecl>(value))
36313631
if (!var->isStatic() && var->isOrdinaryStoredProperty())
36323632
if (auto *varDC = var->getDeclContext())
36333633
if (auto *nominal = varDC->getSelfNominalTypeDecl())
3634-
if (nominal->isValueType())
3634+
if (isa<StructDecl>(nominal))
36353635
return ActorIsolation::forUnspecified();
36363636

36373637
auto typeExpr = TypeExpr::createImplicit(inferred.getGlobalActor(), ctx);

0 commit comments

Comments
 (0)