@@ -2405,6 +2405,23 @@ static bool usesFeatureAsyncAwait(Decl *decl) {
24052405 return true ;
24062406 }
24072407
2408+ // Check for async functions in the types of declarations.
2409+ if (auto value = dyn_cast<ValueDecl>(decl)) {
2410+ if (Type type = value->getInterfaceType ()) {
2411+ bool hasAsync = type.findIf ([](Type type) {
2412+ if (auto fnType = type->getAs <AnyFunctionType>()) {
2413+ if (fnType->isAsync ())
2414+ return true ;
2415+ }
2416+
2417+ return false ;
2418+ });
2419+
2420+ if (hasAsync)
2421+ return true ;
2422+ }
2423+ }
2424+
24082425 return false ;
24092426}
24102427
@@ -2472,6 +2489,23 @@ static bool usesFeatureActors(Decl *decl) {
24722489 return true ;
24732490 }
24742491
2492+ // Check for actors in the types of declarations.
2493+ if (auto value = dyn_cast<ValueDecl>(decl)) {
2494+ if (Type type = value->getInterfaceType ()) {
2495+ bool hasActor = type.findIf ([](Type type) {
2496+ if (auto classDecl = type->getClassOrBoundGenericClass ()) {
2497+ if (classDecl->isActor ())
2498+ return true ;
2499+ }
2500+
2501+ return false ;
2502+ });
2503+
2504+ if (hasActor)
2505+ return true ;
2506+ }
2507+ }
2508+
24752509 return false ;
24762510}
24772511
@@ -2482,11 +2516,6 @@ static bool usesFeatureActors(Decl *decl) {
24822516static std::vector<Feature> getFeaturesUsed (Decl *decl) {
24832517 std::vector<Feature> features;
24842518
2485- // Only type- and module-scope declarations have any features to speak of.
2486- auto dc = decl->getDeclContext ();
2487- if (!dc->isTypeContext () && !dc->isModuleScopeContext ())
2488- return features;
2489-
24902519 // Go through each of the features, checking whether the declaration uses that
24912520 // feature. This also ensures that the resulting set is in sorted order.
24922521#define LANGUAGE_FEATURE (FeatureName, SENumber, Description, Option ) \
0 commit comments