Skip to content

Commit 2801076

Browse files
committed
[CoroutineAccessors] Synthesize modify2 bodies.
Adding a synthesis routine for modify2 separate from that for modify was inadverently omitted during the initial inadverently. Fix that here.
1 parent 5f362c5 commit 2801076

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,6 +2289,20 @@ synthesizeModifyCoroutineBody(AccessorDecl *modify, ASTContext &ctx) {
22892289
return synthesizeCoroutineAccessorBody(modify, ctx);
22902290
}
22912291

2292+
/// Synthesize the body of a modify coroutine.
2293+
static std::pair<BraceStmt *, bool>
2294+
synthesizeModify2CoroutineBody(AccessorDecl *modify, ASTContext &ctx) {
2295+
#ifndef NDEBUG
2296+
auto storage = modify->getStorage();
2297+
auto impl = storage->getReadWriteImpl();
2298+
auto hasWrapper = isa<VarDecl>(storage) &&
2299+
cast<VarDecl>(storage)->hasAttachedPropertyWrapper();
2300+
assert((hasWrapper || impl != ReadWriteImplKind::Modify2) &&
2301+
impl != ReadWriteImplKind::Immutable);
2302+
#endif
2303+
return synthesizeCoroutineAccessorBody(modify, ctx);
2304+
}
2305+
22922306
static std::pair<BraceStmt *, bool>
22932307
synthesizeAccessorBody(AbstractFunctionDecl *fn, void *) {
22942308
auto *accessor = cast<AccessorDecl>(fn);
@@ -2312,9 +2326,11 @@ synthesizeAccessorBody(AbstractFunctionDecl *fn, void *) {
23122326
return synthesizeRead2CoroutineBody(accessor, ctx);
23132327

23142328
case AccessorKind::Modify:
2315-
case AccessorKind::Modify2:
23162329
return synthesizeModifyCoroutineBody(accessor, ctx);
23172330

2331+
case AccessorKind::Modify2:
2332+
return synthesizeModify2CoroutineBody(accessor, ctx);
2333+
23182334
case AccessorKind::WillSet:
23192335
case AccessorKind::DidSet:
23202336
case AccessorKind::Address:

0 commit comments

Comments
 (0)