mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Avoid adding nonisolated twice to synthesized Hashable methods.
https://github.com/apple/swift/pull/42041 introduced a centralized mechanism for adding the `nonisolated` attribute to synthesized decls but did not clean up the existing code that was already doing so for `Hashable` conformances. Resolves rdar://102106591
This commit is contained in:
@@ -554,15 +554,13 @@ deriveHashable_hashInto(
|
||||
/*Throws=*/false,
|
||||
/*GenericParams=*/nullptr, params, returnType, parentDC);
|
||||
hashDecl->setBodySynthesizer(bodySynthesizer);
|
||||
addNonIsolatedToSynthesized(derived.Nominal, hashDecl);
|
||||
hashDecl->copyFormalAccessFrom(derived.Nominal,
|
||||
/*sourceIsParentContext=*/true);
|
||||
|
||||
// The derived hash(into:) for an actor must be non-isolated.
|
||||
if (derived.Nominal->isActor() ||
|
||||
getActorIsolation(derived.Nominal) == ActorIsolation::GlobalActor) {
|
||||
hashDecl->getAttrs().add(new (C) NonisolatedAttr(/*IsImplicit*/true));
|
||||
}
|
||||
if (!addNonIsolatedToSynthesized(derived.Nominal, hashDecl) &&
|
||||
derived.Nominal->isActor())
|
||||
hashDecl->getAttrs().add(new (C) NonisolatedAttr(/*IsImplicit*/ true));
|
||||
|
||||
derived.addMembersToConformanceContext({hashDecl});
|
||||
|
||||
@@ -891,7 +889,6 @@ static ValueDecl *deriveHashable_hashValue(DerivedConformance &derived) {
|
||||
SourceLoc(), C.Id_hashValue, parentDC);
|
||||
hashValueDecl->setInterfaceType(intType);
|
||||
hashValueDecl->setSynthesized();
|
||||
addNonIsolatedToSynthesized(derived.Nominal, hashValueDecl);
|
||||
|
||||
ParameterList *params = ParameterList::createEmpty(C);
|
||||
|
||||
@@ -918,10 +915,9 @@ static ValueDecl *deriveHashable_hashValue(DerivedConformance &derived) {
|
||||
/*sourceIsParentContext*/ true);
|
||||
|
||||
// The derived hashValue of an actor must be nonisolated.
|
||||
if (derived.Nominal->isActor() ||
|
||||
getActorIsolation(derived.Nominal) == ActorIsolation::GlobalActor) {
|
||||
hashValueDecl->getAttrs().add(new (C) NonisolatedAttr(/*IsImplicit*/true));
|
||||
}
|
||||
if (!addNonIsolatedToSynthesized(derived.Nominal, hashValueDecl) &&
|
||||
derived.Nominal->isActor())
|
||||
hashValueDecl->getAttrs().add(new (C) NonisolatedAttr(/*IsImplicit*/ true));
|
||||
|
||||
Pattern *hashValuePat = NamedPattern::createImplicit(C, hashValueDecl);
|
||||
hashValuePat->setType(intType);
|
||||
|
||||
Reference in New Issue
Block a user