@@ -1762,9 +1762,7 @@ namespace {
1762
1762
// /
1763
1763
// / and we reach up to mark the CallExpr.
1764
1764
void markNearestCallAsImplicitly (
1765
- Optional<ImplicitActorHopTarget> setAsync,
1766
- bool setThrows = false ,
1767
- bool setDistributedThunk = false ) {
1765
+ Optional<ImplicitActorHopTarget> setAsync) {
1768
1766
assert (applyStack.size () > 0 && " not contained within an Apply?" );
1769
1767
1770
1768
const auto End = applyStack.rend ();
@@ -1773,14 +1771,6 @@ namespace {
1773
1771
if (setAsync) {
1774
1772
call->setImplicitlyAsync (*setAsync);
1775
1773
}
1776
- if (setThrows) {
1777
- call->setImplicitlyThrows (true );
1778
- }else {
1779
- call->setImplicitlyThrows (false );
1780
- }
1781
- if (setDistributedThunk) {
1782
- call->setUsesDistributedThunk (true );
1783
- }
1784
1774
return ;
1785
1775
}
1786
1776
llvm_unreachable (" expected a CallExpr in applyStack!" );
@@ -2290,42 +2280,30 @@ namespace {
2290
2280
// / isolated to a distributed actor from a location that is potentially not
2291
2281
// / local to this process.
2292
2282
// /
2293
- // / \returns the (setThrows, isDistributedThunk) bits to implicitly
2294
- // / mark the access/call with on success, or emits an error and returns
2295
- // / \c None.
2296
- Optional<std::pair<bool , bool >>
2297
- checkDistributedAccess (SourceLoc declLoc, ValueDecl *decl,
2298
- Expr *context) {
2283
+ // / \returns true if the access is from outside of actors isolation
2284
+ // / context and false otherwise.
2285
+ bool isDistributedAccess (SourceLoc declLoc, ValueDecl *decl,
2286
+ Expr *context) {
2299
2287
// If base of the call is 'local' we permit skip distributed checks.
2300
2288
if (auto baseSelf = findReferencedBaseSelf (context)) {
2301
- if (baseSelf->getAttrs ().hasAttribute <KnownToBeLocalAttr>()) {
2302
- return std::make_pair (
2303
- /* setThrows=*/ false ,
2304
- /* isDistributedThunk=*/ false );
2305
- }
2289
+ if (baseSelf->getAttrs ().hasAttribute <KnownToBeLocalAttr>())
2290
+ return false ;
2306
2291
}
2307
2292
2308
2293
// Cannot reference subscripts, or stored properties.
2309
2294
auto var = dyn_cast<VarDecl>(decl);
2310
2295
if (isa<SubscriptDecl>(decl) || var) {
2311
2296
// But computed distributed properties are okay,
2312
2297
// and treated the same as a distributed func.
2313
- if (var && var->isDistributed ()) {
2314
- bool explicitlyThrowing = false ;
2315
- if (auto getter = var->getAccessor (swift::AccessorKind::Get)) {
2316
- explicitlyThrowing = getter->hasThrows ();
2317
- }
2318
- return std::make_pair (
2319
- /* setThrows*/ !explicitlyThrowing,
2320
- /* isDistributedThunk=*/ true );
2321
- }
2298
+ if (var && var->isDistributed ())
2299
+ return true ;
2322
2300
2323
2301
// otherwise, it was a normal property or subscript and therefore illegal
2324
2302
ctx.Diags .diagnose (
2325
2303
declLoc, diag::distributed_actor_isolated_non_self_reference,
2326
2304
decl->getDescriptiveKind (), decl->getName ());
2327
2305
noteIsolatedActorMember (decl, context);
2328
- return None ;
2306
+ return false ;
2329
2307
}
2330
2308
2331
2309
// Check that we have a distributed function or computed property.
@@ -2336,15 +2314,13 @@ namespace {
2336
2314
.fixItInsert (decl->getAttributeInsertionLoc (true ), " distributed " );
2337
2315
2338
2316
noteIsolatedActorMember (decl, context);
2339
- return None ;
2317
+ return false ;
2340
2318
}
2341
2319
2342
- return std::make_pair (
2343
- /* setThrows=*/ !afd->hasThrows (),
2344
- /* isDistributedThunk=*/ true );
2320
+ return true ;
2345
2321
}
2346
2322
2347
- return std::make_pair ( /* setThrows= */ false , /* distributedThunk= */ false ) ;
2323
+ return false ;
2348
2324
}
2349
2325
2350
2326
// / Attempts to identify and mark a valid cross-actor use of a synchronous
@@ -2362,13 +2338,8 @@ namespace {
2362
2338
if (isPropOrSubscript (decl)) {
2363
2339
// Cannot reference properties or subscripts of distributed actors.
2364
2340
if (isDistributed) {
2365
- bool setThrows = false ;
2366
- bool usesDistributedThunk = false ;
2367
- if (auto access = checkDistributedAccess (declLoc, decl, context)) {
2368
- std::tie (setThrows, usesDistributedThunk) = *access;
2369
- } else {
2341
+ if (!isDistributedAccess (declLoc, decl, context))
2370
2342
return AsyncMarkingResult::NotDistributed;
2371
- }
2372
2343
}
2373
2344
2374
2345
if (auto declRef = dyn_cast_or_null<DeclRefExpr>(context)) {
@@ -2424,20 +2395,13 @@ namespace {
2424
2395
if (isAsyncCall) {
2425
2396
// If we're calling to a distributed actor, make sure the function
2426
2397
// is actually 'distributed'.
2427
- bool setThrows = false ;
2428
- bool usesDistributedThunk = false ;
2429
2398
if (isDistributed) {
2430
- if (auto access = checkDistributedAccess (declLoc, decl, context)) {
2431
- std::tie (setThrows, usesDistributedThunk) = *access;
2432
- } else {
2399
+ if (!isDistributedAccess (declLoc, decl, context))
2433
2400
return AsyncMarkingResult::NotDistributed;
2434
- }
2435
2401
}
2436
2402
2437
- // Mark call as implicitly 'async', and also potentially as
2438
- // throwing and using a distributed thunk.
2439
- markNearestCallAsImplicitly (
2440
- /* setAsync=*/ target, setThrows, usesDistributedThunk);
2403
+ // Mark call as implicitly 'async'.
2404
+ markNearestCallAsImplicitly (/* setAsync=*/ target);
2441
2405
result = AsyncMarkingResult::FoundAsync;
2442
2406
}
2443
2407
0 commit comments