File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -2395,10 +2395,15 @@ getDirectReadAccessStrategy(const AbstractStorageDecl *storage) {
2395
2395
static AccessStrategy
2396
2396
getDirectWriteAccessStrategy (const AbstractStorageDecl *storage) {
2397
2397
switch (storage->getWriteImpl ()) {
2398
- case WriteImplKind::Immutable:
2398
+ case WriteImplKind::Immutable: {
2399
+ if (storage->hasInitAccessor ())
2400
+ return AccessStrategy::getAccessor (AccessorKind::Init,
2401
+ /* dispatch=*/ false );
2402
+
2399
2403
assert (isa<VarDecl>(storage) && cast<VarDecl>(storage)->isLet () &&
2400
2404
" mutation of a immutable variable that isn't a let" );
2401
2405
return AccessStrategy::getStorage ();
2406
+ }
2402
2407
case WriteImplKind::Stored:
2403
2408
return AccessStrategy::getStorage ();
2404
2409
case WriteImplKind::StoredWithObservers:
@@ -2475,7 +2480,9 @@ getOpaqueReadAccessStrategy(const AbstractStorageDecl *storage, bool dispatch) {
2475
2480
}
2476
2481
2477
2482
static AccessStrategy
2478
- getOpaqueWriteAccessStrategy (const AbstractStorageDecl *storage, bool dispatch){
2483
+ getOpaqueWriteAccessStrategy (const AbstractStorageDecl *storage, bool dispatch) {
2484
+ if (storage->hasInitAccessor () && !storage->getAccessor (AccessorKind::Set))
2485
+ return AccessStrategy::getAccessor (AccessorKind::Init, dispatch);
2479
2486
return AccessStrategy::getAccessor (AccessorKind::Set, dispatch);
2480
2487
}
2481
2488
You can’t perform that action at this time.
0 commit comments