@@ -2405,6 +2405,23 @@ static bool usesFeatureAsyncAwait(Decl *decl) {
2405
2405
return true ;
2406
2406
}
2407
2407
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
+
2408
2425
return false ;
2409
2426
}
2410
2427
@@ -2472,6 +2489,23 @@ static bool usesFeatureActors(Decl *decl) {
2472
2489
return true ;
2473
2490
}
2474
2491
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
+
2475
2509
return false ;
2476
2510
}
2477
2511
@@ -2482,11 +2516,6 @@ static bool usesFeatureActors(Decl *decl) {
2482
2516
static std::vector<Feature> getFeaturesUsed (Decl *decl) {
2483
2517
std::vector<Feature> features;
2484
2518
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
-
2490
2519
// Go through each of the features, checking whether the declaration uses that
2491
2520
// feature. This also ensures that the resulting set is in sorted order.
2492
2521
#define LANGUAGE_FEATURE (FeatureName, SENumber, Description, Option ) \
0 commit comments