@@ -632,25 +632,6 @@ void ASTContext::lookupInSwiftModule(
632
632
M->lookupValue ({ }, identifier, NLKind::UnqualifiedLookup, results);
633
633
}
634
634
635
- // / Find the generic implementation declaration for the named syntactic-sugar
636
- // / type.
637
- static NominalTypeDecl *findStdlibType (const ASTContext &ctx, StringRef name,
638
- unsigned genericParams) {
639
- // Find all of the declarations with this name in the Swift module.
640
- SmallVector<ValueDecl *, 1 > results;
641
- ctx.lookupInSwiftModule (name, results);
642
- for (auto result : results) {
643
- if (auto nominal = dyn_cast<NominalTypeDecl>(result)) {
644
- auto params = nominal->getGenericParams ();
645
- if (genericParams == (params == nullptr ? 0 : params->size ())) {
646
- // We found it.
647
- return nominal;
648
- }
649
- }
650
- }
651
- return nullptr ;
652
- }
653
-
654
635
FuncDecl *ASTContext::getPlusFunctionOnRangeReplaceableCollection () const {
655
636
if (getImpl ().PlusFunctionOnRangeReplaceableCollection ) {
656
637
return getImpl ().PlusFunctionOnRangeReplaceableCollection ;
@@ -707,10 +688,19 @@ FuncDecl *ASTContext::getPlusFunctionOnString() const {
707
688
708
689
#define KNOWN_STDLIB_TYPE_DECL (NAME, DECL_CLASS, NUM_GENERIC_PARAMS ) \
709
690
DECL_CLASS *ASTContext::get##NAME##Decl() const { \
710
- if (!getImpl ().NAME ##Decl) \
711
- getImpl ().NAME ##Decl = dyn_cast_or_null<DECL_CLASS>( \
712
- findStdlibType (*this , #NAME, NUM_GENERIC_PARAMS)); \
713
- return getImpl ().NAME ##Decl; \
691
+ if (getImpl ().NAME ##Decl) \
692
+ return getImpl ().NAME ##Decl; \
693
+ SmallVector<ValueDecl *, 1 > results; \
694
+ lookupInSwiftModule (#NAME, results); \
695
+ for (auto result : results) { \
696
+ if (auto type = dyn_cast<DECL_CLASS>(result)) { \
697
+ auto params = type->getGenericParams (); \
698
+ if (NUM_GENERIC_PARAMS == (params == nullptr ? 0 : params->size ())) { \
699
+ return type; \
700
+ } \
701
+ } \
702
+ } \
703
+ return nullptr ; \
714
704
}
715
705
#include " swift/AST/KnownStdlibTypes.def"
716
706
0 commit comments