@@ -5064,7 +5064,13 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
50645064 bool onlyExplicit = false ) {
50655065 // Look up attributes on the declaration that can affect its actor isolation.
50665066 // If any of them are present, use that attribute.
5067- auto isolatedAttr = decl->getAttrs ().getAttribute <IsolatedAttr>();
5067+
5068+ // 'isolated` attribute in the declaration context currently applies
5069+ // only to `deinit` declarations, invalid uses are going to
5070+ // be diagnosed as part of attribute checking.
5071+ auto isolatedAttr = isa<DestructorDecl>(decl)
5072+ ? decl->getAttrs ().getAttribute <IsolatedAttr>()
5073+ : nullptr ;
50685074 auto nonisolatedAttr = decl->getAttrs ().getAttribute <NonisolatedAttr>();
50695075 auto globalActorAttr = decl->getGlobalActorAttr ();
50705076 auto concurrentAttr = decl->getAttrs ().getAttribute <ConcurrentAttr>();
@@ -5117,10 +5123,8 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
51175123 }
51185124
51195125 // If the declaration is explicitly marked 'isolated', infer actor isolation
5120- // from the context. Currently applies only to DestructorDecl
5126+ // from the context. Currently applies only to DestructorDecl.
51215127 if (isolatedAttr) {
5122- assert (isa<DestructorDecl>(decl));
5123-
51245128 auto dc = decl->getDeclContext ();
51255129 auto selfTypeDecl = dc->getSelfNominalTypeDecl ();
51265130 std::optional<ActorIsolation> result;
0 commit comments