@@ -4219,6 +4219,11 @@ NeverNullType TypeResolver::resolveASTFunctionType(
42194219 attr->getAttrName ());
42204220 }
42214221
4222+ if (options.contains (TypeResolutionFlags::InheritsActorContext)) {
4223+ diagnoseInvalid (repr, attr->getAttrLoc (),
4224+ diag::inherit_actor_context_with_concurrent, attr);
4225+ }
4226+
42224227 switch (isolation.getKind ()) {
42234228 case FunctionTypeIsolation::Kind::NonIsolated:
42244229 break ;
@@ -4265,18 +4270,20 @@ NeverNullType TypeResolver::resolveASTFunctionType(
42654270 if (!repr->isInvalid ())
42664271 isolation = FunctionTypeIsolation::forNonIsolated ();
42674272 } 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+ }
42804287 }
42814288 }
42824289 }
@@ -5326,6 +5333,12 @@ TypeResolver::resolveCallerIsolatedTypeRepr(CallerIsolatedTypeRepr *repr,
53265333 return ErrorType::get (getASTContext ());
53275334 }
53285335
5336+ if (options.contains (TypeResolutionFlags::InheritsActorContext)) {
5337+ diagnoseInvalid (repr, repr->getLoc (),
5338+ diag::inherit_actor_context_with_nonisolated_nonsending,
5339+ repr);
5340+ }
5341+
53295342 if (!fnType->isAsync ()) {
53305343 diagnoseInvalid (repr, repr->getStartLoc (),
53315344 diag::nonisolated_nonsending_only_on_async, repr);
0 commit comments