@@ -2398,47 +2398,47 @@ ActorIsolation ActorIsolationRequest::evaluate(
2398
2398
return getActorIsolation (accessor->getStorage ());
2399
2399
}
2400
2400
2401
- if (shouldInferAttributeInContext (value->getDeclContext ())) {
2402
- if (auto var = dyn_cast<VarDecl>(value)) {
2403
- // If this is a variable with a property wrapper, infer from the property
2404
- // wrapper's wrappedValue.
2405
- if (auto wrapperInfo = var->getAttachedPropertyWrapperTypeInfo (0 )) {
2406
- if (auto wrappedValue = wrapperInfo.valueVar ) {
2407
- if (auto isolation = getActorIsolation (wrappedValue))
2408
- return inferredIsolation (isolation, /* propagateUnsafe=*/ true );
2409
- }
2410
- }
2411
-
2412
- // If this is the backing storage for a property wrapper, infer from the
2413
- // type of the outermost property wrapper.
2414
- if (auto originalVar = var->getOriginalWrappedProperty (
2415
- PropertyWrapperSynthesizedPropertyKind::Backing)) {
2416
- if (auto backingType =
2417
- originalVar->getPropertyWrapperBackingPropertyType ()) {
2418
- if (auto backingNominal = backingType->getAnyNominal ()) {
2419
- if (!isa<ClassDecl>(backingNominal) ||
2420
- !cast<ClassDecl>(backingNominal)->isActor ()) {
2421
- if (auto isolation = getActorIsolation (backingNominal))
2422
- return inferredIsolation (isolation, /* propagateUnsafe=*/ true );
2423
- }
2401
+ if (auto var = dyn_cast<VarDecl>(value)) {
2402
+ // If this is a variable with a property wrapper, infer from the property
2403
+ // wrapper's wrappedValue.
2404
+ if (auto wrapperInfo = var->getAttachedPropertyWrapperTypeInfo (0 )) {
2405
+ if (auto wrappedValue = wrapperInfo.valueVar ) {
2406
+ if (auto isolation = getActorIsolation (wrappedValue))
2407
+ return inferredIsolation (isolation, /* propagateUnsafe=*/ true );
2408
+ }
2409
+ }
2410
+
2411
+ // If this is the backing storage for a property wrapper, infer from the
2412
+ // type of the outermost property wrapper.
2413
+ if (auto originalVar = var->getOriginalWrappedProperty (
2414
+ PropertyWrapperSynthesizedPropertyKind::Backing)) {
2415
+ if (auto backingType =
2416
+ originalVar->getPropertyWrapperBackingPropertyType ()) {
2417
+ if (auto backingNominal = backingType->getAnyNominal ()) {
2418
+ if (!isa<ClassDecl>(backingNominal) ||
2419
+ !cast<ClassDecl>(backingNominal)->isActor ()) {
2420
+ if (auto isolation = getActorIsolation (backingNominal))
2421
+ return inferredIsolation (isolation, /* propagateUnsafe=*/ true );
2424
2422
}
2425
2423
}
2426
2424
}
2425
+ }
2427
2426
2428
- // If this is the projected property for a property wrapper, infer from
2429
- // the property wrapper's projectedValue.
2430
- if (auto originalVar = var->getOriginalWrappedProperty (
2431
- PropertyWrapperSynthesizedPropertyKind::Projection)) {
2432
- if (auto wrapperInfo =
2433
- originalVar->getAttachedPropertyWrapperTypeInfo (0 )) {
2434
- if (auto projectedValue = wrapperInfo.projectedValueVar ) {
2435
- if (auto isolation = getActorIsolation (projectedValue))
2436
- return inferredIsolation (isolation, /* propagateUnsafe=*/ true );
2437
- }
2427
+ // If this is the projected property for a property wrapper, infer from
2428
+ // the property wrapper's projectedValue.
2429
+ if (auto originalVar = var->getOriginalWrappedProperty (
2430
+ PropertyWrapperSynthesizedPropertyKind::Projection)) {
2431
+ if (auto wrapperInfo =
2432
+ originalVar->getAttachedPropertyWrapperTypeInfo (0 )) {
2433
+ if (auto projectedValue = wrapperInfo.projectedValueVar ) {
2434
+ if (auto isolation = getActorIsolation (projectedValue))
2435
+ return inferredIsolation (isolation, /* propagateUnsafe=*/ true );
2438
2436
}
2439
2437
}
2440
2438
}
2439
+ }
2441
2440
2441
+ if (shouldInferAttributeInContext (value->getDeclContext ())) {
2442
2442
// If the declaration witnesses a protocol requirement that is isolated,
2443
2443
// use that.
2444
2444
if (auto witnessedIsolation = getIsolationFromWitnessedRequirements (value)) {
@@ -2615,6 +2615,13 @@ static bool shouldDiagnoseExistingDataRaces(const DeclContext *dc) {
2615
2615
// features.
2616
2616
if (func->getAttrs ().hasAttribute <AsyncHandlerAttr>())
2617
2617
return true ;
2618
+
2619
+ // If we're in an accessor declaration, also check the storage
2620
+ // declaration.
2621
+ if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
2622
+ if (getIsolationFromAttributes (accessor->getStorage ()))
2623
+ return true ;
2624
+ }
2618
2625
}
2619
2626
}
2620
2627
0 commit comments