@@ -1044,7 +1044,8 @@ namespace {
1044
1044
// / the given parsed type representation.
1045
1045
static DirectlyReferencedTypeDecls
1046
1046
directReferencesForTypeRepr (Evaluator &evaluator, ASTContext &ctx,
1047
- TypeRepr *typeRepr, DeclContext *dc);
1047
+ TypeRepr *typeRepr, DeclContext *dc,
1048
+ bool allowUsableFromInline=false );
1048
1049
1049
1050
// / Retrieve the set of type declarations that are directly referenced from
1050
1051
// / the given type.
@@ -2325,7 +2326,8 @@ resolveTypeDeclsToNominal(Evaluator &evaluator,
2325
2326
static DirectlyReferencedTypeDecls
2326
2327
directReferencesForUnqualifiedTypeLookup (DeclNameRef name,
2327
2328
SourceLoc loc, DeclContext *dc,
2328
- LookupOuterResults lookupOuter) {
2329
+ LookupOuterResults lookupOuter,
2330
+ bool allowUsableFromInline=false ) {
2329
2331
// In a protocol or protocol extension, the 'where' clause can refer to
2330
2332
// associated types without 'Self' qualification:
2331
2333
//
@@ -2359,6 +2361,9 @@ directReferencesForUnqualifiedTypeLookup(DeclNameRef name,
2359
2361
if (lookupOuter == LookupOuterResults::Included)
2360
2362
options |= UnqualifiedLookupFlags::IncludeOuterResults;
2361
2363
2364
+ if (allowUsableFromInline)
2365
+ options |= UnqualifiedLookupFlags::IncludeUsableFromInline;
2366
+
2362
2367
auto &ctx = dc->getASTContext ();
2363
2368
auto descriptor = UnqualifiedLookupDescriptor (name, dc, loc, options);
2364
2369
auto lookup = evaluateOrDefault (ctx.evaluator ,
@@ -2388,7 +2393,8 @@ directReferencesForQualifiedTypeLookup(Evaluator &evaluator,
2388
2393
ASTContext &ctx,
2389
2394
ArrayRef<TypeDecl *> baseTypes,
2390
2395
DeclNameRef name,
2391
- DeclContext *dc) {
2396
+ DeclContext *dc,
2397
+ bool allowUsableFromInline=false ) {
2392
2398
DirectlyReferencedTypeDecls result;
2393
2399
auto addResults = [&result](ArrayRef<ValueDecl *> found){
2394
2400
for (auto decl : found){
@@ -2403,6 +2409,9 @@ directReferencesForQualifiedTypeLookup(Evaluator &evaluator,
2403
2409
SmallVector<ValueDecl *, 4 > members;
2404
2410
auto options = NL_RemoveNonVisible | NL_OnlyTypes;
2405
2411
2412
+ if (allowUsableFromInline)
2413
+ options |= NL_IncludeUsableFromInline;
2414
+
2406
2415
// Look through the type declarations we were given, resolving them down
2407
2416
// to nominal type declarations, module declarations, and
2408
2417
SmallVector<ModuleDecl *, 2 > moduleDecls;
@@ -2433,7 +2442,7 @@ directReferencesForQualifiedTypeLookup(Evaluator &evaluator,
2433
2442
static DirectlyReferencedTypeDecls
2434
2443
directReferencesForIdentTypeRepr (Evaluator &evaluator,
2435
2444
ASTContext &ctx, IdentTypeRepr *ident,
2436
- DeclContext *dc) {
2445
+ DeclContext *dc, bool allowUsableFromInline ) {
2437
2446
DirectlyReferencedTypeDecls current;
2438
2447
2439
2448
for (const auto &component : ident->getComponentRange ()) {
@@ -2449,7 +2458,8 @@ directReferencesForIdentTypeRepr(Evaluator &evaluator,
2449
2458
directReferencesForUnqualifiedTypeLookup (component->getNameRef (),
2450
2459
component->getLoc (),
2451
2460
dc,
2452
- LookupOuterResults::Excluded);
2461
+ LookupOuterResults::Excluded,
2462
+ allowUsableFromInline);
2453
2463
2454
2464
// If we didn't find anything, fail now.
2455
2465
if (current.empty ())
@@ -2461,7 +2471,8 @@ directReferencesForIdentTypeRepr(Evaluator &evaluator,
2461
2471
// For subsequent components, perform qualified name lookup.
2462
2472
current =
2463
2473
directReferencesForQualifiedTypeLookup (evaluator, ctx, current,
2464
- component->getNameRef (), dc);
2474
+ component->getNameRef (), dc,
2475
+ allowUsableFromInline);
2465
2476
if (current.empty ())
2466
2477
return current;
2467
2478
}
@@ -2472,23 +2483,25 @@ directReferencesForIdentTypeRepr(Evaluator &evaluator,
2472
2483
static DirectlyReferencedTypeDecls
2473
2484
directReferencesForTypeRepr (Evaluator &evaluator,
2474
2485
ASTContext &ctx, TypeRepr *typeRepr,
2475
- DeclContext *dc) {
2486
+ DeclContext *dc, bool allowUsableFromInline ) {
2476
2487
switch (typeRepr->getKind ()) {
2477
2488
case TypeReprKind::Array:
2478
2489
return {1 , ctx.getArrayDecl ()};
2479
2490
2480
2491
case TypeReprKind::Attributed: {
2481
2492
auto attributed = cast<AttributedTypeRepr>(typeRepr);
2482
2493
return directReferencesForTypeRepr (evaluator, ctx,
2483
- attributed->getTypeRepr (), dc);
2494
+ attributed->getTypeRepr (), dc,
2495
+ allowUsableFromInline);
2484
2496
}
2485
2497
2486
2498
case TypeReprKind::Composition: {
2487
2499
DirectlyReferencedTypeDecls result;
2488
2500
auto composition = cast<CompositionTypeRepr>(typeRepr);
2489
2501
for (auto component : composition->getTypes ()) {
2490
2502
auto componentResult =
2491
- directReferencesForTypeRepr (evaluator, ctx, component, dc);
2503
+ directReferencesForTypeRepr (evaluator, ctx, component, dc,
2504
+ allowUsableFromInline);
2492
2505
result.insert (result.end (),
2493
2506
componentResult.begin (),
2494
2507
componentResult.end ());
@@ -2500,7 +2513,8 @@ directReferencesForTypeRepr(Evaluator &evaluator,
2500
2513
case TypeReprKind::GenericIdent:
2501
2514
case TypeReprKind::SimpleIdent:
2502
2515
return directReferencesForIdentTypeRepr (evaluator, ctx,
2503
- cast<IdentTypeRepr>(typeRepr), dc);
2516
+ cast<IdentTypeRepr>(typeRepr), dc,
2517
+ allowUsableFromInline);
2504
2518
2505
2519
case TypeReprKind::Dictionary:
2506
2520
return { 1 , ctx.getDictionaryDecl ()};
@@ -2509,7 +2523,8 @@ directReferencesForTypeRepr(Evaluator &evaluator,
2509
2523
auto tupleRepr = cast<TupleTypeRepr>(typeRepr);
2510
2524
if (tupleRepr->isParenType ()) {
2511
2525
return directReferencesForTypeRepr (evaluator, ctx,
2512
- tupleRepr->getElementType (0 ), dc);
2526
+ tupleRepr->getElementType (0 ), dc,
2527
+ allowUsableFromInline);
2513
2528
}
2514
2529
return { };
2515
2530
}
@@ -2715,7 +2730,8 @@ ExtendedNominalRequest::evaluate(Evaluator &evaluator,
2715
2730
2716
2731
ASTContext &ctx = ext->getASTContext ();
2717
2732
DirectlyReferencedTypeDecls referenced =
2718
- directReferencesForTypeRepr (evaluator, ctx, typeRepr, ext->getParent ());
2733
+ directReferencesForTypeRepr (evaluator, ctx, typeRepr, ext->getParent (),
2734
+ ext->isInSpecializeExtensionContext ());
2719
2735
2720
2736
// Resolve those type declarations to nominal type declarations.
2721
2737
SmallVector<ModuleDecl *, 2 > modulesFound;
0 commit comments