@@ -4219,6 +4219,11 @@ NeverNullType TypeResolver::resolveASTFunctionType(
4219
4219
attr->getAttrName ());
4220
4220
}
4221
4221
4222
+ if (options.contains (TypeResolutionFlags::InheritsActorContext)) {
4223
+ diagnoseInvalid (repr, attr->getAttrLoc (),
4224
+ diag::inherit_actor_context_with_concurrent, attr);
4225
+ }
4226
+
4222
4227
switch (isolation.getKind ()) {
4223
4228
case FunctionTypeIsolation::Kind::NonIsolated:
4224
4229
break ;
@@ -4265,18 +4270,20 @@ NeverNullType TypeResolver::resolveASTFunctionType(
4265
4270
if (!repr->isInvalid ())
4266
4271
isolation = FunctionTypeIsolation::forNonIsolated ();
4267
4272
} else if (!getWithoutClaiming<CallerIsolatedTypeRepr>(attrs)) {
4268
- // Infer async function type as `nonisolated(nonsending)` if there is
4269
- // no `@concurrent` or `nonisolated(nonsending)` attribute and isolation
4270
- // is nonisolated.
4271
- if (ctx.LangOpts .hasFeature (Feature::NonisolatedNonsendingByDefault) &&
4272
- repr->isAsync () && isolation.isNonIsolated ()) {
4273
- isolation = FunctionTypeIsolation::forNonIsolatedCaller ();
4274
- } else if (ctx.LangOpts
4275
- .getFeatureState (Feature::NonisolatedNonsendingByDefault)
4276
- .isEnabledForMigration ()) {
4277
- // Diagnose only in the interface stage, which is run once.
4278
- if (inStage (TypeResolutionStage::Interface)) {
4279
- warnAboutNewNonisolatedAsyncExecutionBehavior (ctx, repr, isolation);
4273
+ if (!options.contains (TypeResolutionFlags::InheritsActorContext)) {
4274
+ // Infer async function type as `nonisolated(nonsending)` if there is
4275
+ // no `@concurrent` or `nonisolated(nonsending)` attribute and isolation
4276
+ // is nonisolated.
4277
+ if (ctx.LangOpts .hasFeature (Feature::NonisolatedNonsendingByDefault) &&
4278
+ repr->isAsync () && isolation.isNonIsolated ()) {
4279
+ isolation = FunctionTypeIsolation::forNonIsolatedCaller ();
4280
+ } else if (ctx.LangOpts
4281
+ .getFeatureState (Feature::NonisolatedNonsendingByDefault)
4282
+ .isEnabledForMigration ()) {
4283
+ // Diagnose only in the interface stage, which is run once.
4284
+ if (inStage (TypeResolutionStage::Interface)) {
4285
+ warnAboutNewNonisolatedAsyncExecutionBehavior (ctx, repr, isolation);
4286
+ }
4280
4287
}
4281
4288
}
4282
4289
}
@@ -5326,6 +5333,12 @@ TypeResolver::resolveCallerIsolatedTypeRepr(CallerIsolatedTypeRepr *repr,
5326
5333
return ErrorType::get (getASTContext ());
5327
5334
}
5328
5335
5336
+ if (options.contains (TypeResolutionFlags::InheritsActorContext)) {
5337
+ diagnoseInvalid (repr, repr->getLoc (),
5338
+ diag::inherit_actor_context_with_nonisolated_nonsending,
5339
+ repr);
5340
+ }
5341
+
5329
5342
if (!fnType->isAsync ()) {
5330
5343
diagnoseInvalid (repr, repr->getStartLoc (),
5331
5344
diag::nonisolated_nonsending_only_on_async, repr);
0 commit comments