@@ -1721,9 +1721,7 @@ namespace {
1721
1721
// /
1722
1722
// / and we reach up to mark the CallExpr.
1723
1723
void markNearestCallAsImplicitly (
1724
- Optional<ImplicitActorHopTarget> setAsync,
1725
- bool setThrows = false ,
1726
- bool setDistributedThunk = false ) {
1724
+ Optional<ImplicitActorHopTarget> setAsync) {
1727
1725
assert (applyStack.size () > 0 && " not contained within an Apply?" );
1728
1726
1729
1727
const auto End = applyStack.rend ();
@@ -1732,14 +1730,6 @@ namespace {
1732
1730
if (setAsync) {
1733
1731
call->setImplicitlyAsync (*setAsync);
1734
1732
}
1735
- if (setThrows) {
1736
- call->setImplicitlyThrows (true );
1737
- }else {
1738
- call->setImplicitlyThrows (false );
1739
- }
1740
- if (setDistributedThunk) {
1741
- call->setUsesDistributedThunk (true );
1742
- }
1743
1733
return ;
1744
1734
}
1745
1735
llvm_unreachable (" expected a CallExpr in applyStack!" );
@@ -2240,42 +2230,30 @@ namespace {
2240
2230
// / isolated to a distributed actor from a location that is potentially not
2241
2231
// / local to this process.
2242
2232
// /
2243
- // / \returns the (setThrows, isDistributedThunk) bits to implicitly
2244
- // / mark the access/call with on success, or emits an error and returns
2245
- // / \c None.
2246
- Optional<std::pair<bool , bool >>
2247
- checkDistributedAccess (SourceLoc declLoc, ValueDecl *decl,
2248
- Expr *context) {
2233
+ // / \returns true if the access is from outside of actors isolation
2234
+ // / context and false otherwise.
2235
+ bool isDistributedAccess (SourceLoc declLoc, ValueDecl *decl,
2236
+ Expr *context) {
2249
2237
// If base of the call is 'local' we permit skip distributed checks.
2250
2238
if (auto baseSelf = findReferencedBaseSelf (context)) {
2251
- if (baseSelf->getAttrs ().hasAttribute <KnownToBeLocalAttr>()) {
2252
- return std::make_pair (
2253
- /* setThrows=*/ false ,
2254
- /* isDistributedThunk=*/ false );
2255
- }
2239
+ if (baseSelf->getAttrs ().hasAttribute <KnownToBeLocalAttr>())
2240
+ return false ;
2256
2241
}
2257
2242
2258
2243
// Cannot reference subscripts, or stored properties.
2259
2244
auto var = dyn_cast<VarDecl>(decl);
2260
2245
if (isa<SubscriptDecl>(decl) || var) {
2261
2246
// But computed distributed properties are okay,
2262
2247
// and treated the same as a distributed func.
2263
- if (var && var->isDistributed ()) {
2264
- bool explicitlyThrowing = false ;
2265
- if (auto getter = var->getAccessor (swift::AccessorKind::Get)) {
2266
- explicitlyThrowing = getter->hasThrows ();
2267
- }
2268
- return std::make_pair (
2269
- /* setThrows*/ !explicitlyThrowing,
2270
- /* isDistributedThunk=*/ true );
2271
- }
2248
+ if (var && var->isDistributed ())
2249
+ return true ;
2272
2250
2273
2251
// otherwise, it was a normal property or subscript and therefore illegal
2274
2252
ctx.Diags .diagnose (
2275
2253
declLoc, diag::distributed_actor_isolated_non_self_reference,
2276
2254
decl->getDescriptiveKind (), decl->getName ());
2277
2255
noteIsolatedActorMember (decl, context);
2278
- return None ;
2256
+ return false ;
2279
2257
}
2280
2258
2281
2259
// Check that we have a distributed function or computed property.
@@ -2286,15 +2264,13 @@ namespace {
2286
2264
.fixItInsert (decl->getAttributeInsertionLoc (true ), " distributed " );
2287
2265
2288
2266
noteIsolatedActorMember (decl, context);
2289
- return None ;
2267
+ return false ;
2290
2268
}
2291
2269
2292
- return std::make_pair (
2293
- /* setThrows=*/ !afd->hasThrows (),
2294
- /* isDistributedThunk=*/ true );
2270
+ return true ;
2295
2271
}
2296
2272
2297
- return std::make_pair ( /* setThrows= */ false , /* distributedThunk= */ false ) ;
2273
+ return false ;
2298
2274
}
2299
2275
2300
2276
// / Attempts to identify and mark a valid cross-actor use of a synchronous
@@ -2312,13 +2288,8 @@ namespace {
2312
2288
if (isPropOrSubscript (decl)) {
2313
2289
// Cannot reference properties or subscripts of distributed actors.
2314
2290
if (isDistributed) {
2315
- bool setThrows = false ;
2316
- bool usesDistributedThunk = false ;
2317
- if (auto access = checkDistributedAccess (declLoc, decl, context)) {
2318
- std::tie (setThrows, usesDistributedThunk) = *access;
2319
- } else {
2291
+ if (!isDistributedAccess (declLoc, decl, context))
2320
2292
return AsyncMarkingResult::NotDistributed;
2321
- }
2322
2293
}
2323
2294
2324
2295
if (auto declRef = dyn_cast_or_null<DeclRefExpr>(context)) {
@@ -2374,20 +2345,13 @@ namespace {
2374
2345
if (isAsyncCall) {
2375
2346
// If we're calling to a distributed actor, make sure the function
2376
2347
// is actually 'distributed'.
2377
- bool setThrows = false ;
2378
- bool usesDistributedThunk = false ;
2379
2348
if (isDistributed) {
2380
- if (auto access = checkDistributedAccess (declLoc, decl, context)) {
2381
- std::tie (setThrows, usesDistributedThunk) = *access;
2382
- } else {
2349
+ if (!isDistributedAccess (declLoc, decl, context))
2383
2350
return AsyncMarkingResult::NotDistributed;
2384
- }
2385
2351
}
2386
2352
2387
- // Mark call as implicitly 'async', and also potentially as
2388
- // throwing and using a distributed thunk.
2389
- markNearestCallAsImplicitly (
2390
- /* setAsync=*/ target, setThrows, usesDistributedThunk);
2353
+ // Mark call as implicitly 'async'.
2354
+ markNearestCallAsImplicitly (/* setAsync=*/ target);
2391
2355
result = AsyncMarkingResult::FoundAsync;
2392
2356
}
2393
2357
0 commit comments