@@ -350,21 +350,31 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
350
350
// initializers apply Sendable checking to arguments at the call-site,
351
351
// and actor initializers do not run on the actor, so initial values
352
352
// cannot be actor-instance-isolated.
353
- bool shouldAddNonisolated = true ;
354
353
ActorIsolation existingIsolation = getActorIsolation (decl);
355
354
VarDecl *previousVar = nullptr ;
355
+ bool hasError = false ;
356
356
357
- for (auto member : decl->getImplementationContext ()->getAllMembers ()) {
358
- bool hasError = false ;
359
- auto pbd = dyn_cast<PatternBindingDecl>(member);
360
- if (!pbd || pbd->isStatic ())
361
- continue ;
357
+ // FIXME: Calling `getAllMembers` here causes issues for conformance
358
+ // synthesis to RawRepresentable and friends. Instead, iterate over
359
+ // both the stored properties and the init accessor properties, as
360
+ // those can participate in implicit initializers.
362
361
363
- for (auto i : range (pbd->getNumPatternEntries ())) {
364
- if (pbd->isInitializerSubsumed (i))
362
+ auto stored = decl->getStoredProperties ();
363
+ auto initAccessor = decl->getInitAccessorProperties ();
364
+
365
+ auto shouldAddNonisolated = [&](ArrayRef<VarDecl *> properties) {
366
+ if (hasError)
367
+ return false ;
368
+
369
+ bool addNonisolated = true ;
370
+ for (auto *var : properties) {
371
+ auto *pbd = var->getParentPatternBinding ();
372
+ if (!pbd)
365
373
continue ;
366
374
367
- auto *var = pbd->getAnchoringVarDecl (i);
375
+ auto i = pbd->getPatternEntryIndexForVarDecl (var);
376
+ if (pbd->isInitializerSubsumed (i))
377
+ continue ;
368
378
369
379
ActorIsolation initIsolation;
370
380
if (var->hasInitAccessor ()) {
@@ -401,21 +411,21 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
401
411
var->getDescriptiveKind (),
402
412
var->getName (), isolation);
403
413
hasError = true ;
404
- break ;
414
+ return false ;
405
415
}
406
416
407
417
existingIsolation = isolation;
408
418
previousVar = var;
409
- shouldAddNonisolated = false ;
419
+ addNonisolated = false ;
410
420
}
411
421
}
412
422
}
413
423
414
- if (hasError)
415
- break ;
416
- }
424
+ return addNonisolated;
425
+ };
417
426
418
- if (shouldAddNonisolated) {
427
+ if (shouldAddNonisolated (stored) &&
428
+ shouldAddNonisolated (initAccessor)) {
419
429
addNonIsolatedToSynthesized (decl, ctor);
420
430
}
421
431
}
0 commit comments