@@ -349,21 +349,31 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
349349 // initializers apply Sendable checking to arguments at the call-site,
350350 // and actor initializers do not run on the actor, so initial values
351351 // cannot be actor-instance-isolated.
352- bool shouldAddNonisolated = true ;
353352 ActorIsolation existingIsolation = getActorIsolation (decl);
354353 VarDecl *previousVar = nullptr ;
354+ bool hasError = false ;
355355
356- for (auto member : decl->getImplementationContext ()->getAllMembers ()) {
357- bool hasError = false ;
358- auto pbd = dyn_cast<PatternBindingDecl>(member);
359- if (!pbd || pbd->isStatic ())
360- continue ;
356+ // FIXME: Calling `getAllMembers` here causes issues for conformance
357+ // synthesis to RawRepresentable and friends. Instead, iterate over
358+ // both the stored properties and the init accessor properties, as
359+ // those can participate in implicit initializers.
361360
362- for (auto i : range (pbd->getNumPatternEntries ())) {
363- if (pbd->isInitializerSubsumed (i))
361+ auto stored = decl->getStoredProperties ();
362+ auto initAccessor = decl->getInitAccessorProperties ();
363+
364+ auto shouldAddNonisolated = [&](ArrayRef<VarDecl *> properties) {
365+ if (hasError)
366+ return false ;
367+
368+ bool addNonisolated = true ;
369+ for (auto *var : properties) {
370+ auto *pbd = var->getParentPatternBinding ();
371+ if (!pbd)
364372 continue ;
365373
366- auto *var = pbd->getAnchoringVarDecl (i);
374+ auto i = pbd->getPatternEntryIndexForVarDecl (var);
375+ if (pbd->isInitializerSubsumed (i))
376+ continue ;
367377
368378 ActorIsolation initIsolation;
369379 if (var->hasInitAccessor ()) {
@@ -400,21 +410,21 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
400410 var->getDescriptiveKind (),
401411 var->getName (), isolation);
402412 hasError = true ;
403- break ;
413+ return false ;
404414 }
405415
406416 existingIsolation = isolation;
407417 previousVar = var;
408- shouldAddNonisolated = false ;
418+ addNonisolated = false ;
409419 }
410420 }
411421 }
412422
413- if (hasError)
414- break ;
415- }
423+ return addNonisolated;
424+ };
416425
417- if (shouldAddNonisolated) {
426+ if (shouldAddNonisolated (stored) &&
427+ shouldAddNonisolated (initAccessor)) {
418428 addNonIsolatedToSynthesized (decl, ctor);
419429 }
420430 }
0 commit comments