Skip to content

Commit d541681

Browse files
committed
fix void getter
1 parent 7c75836 commit d541681

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

lib/AST/ASTContext.cpp

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -632,25 +632,6 @@ void ASTContext::lookupInSwiftModule(
632632
M->lookupValue({ }, identifier, NLKind::UnqualifiedLookup, results);
633633
}
634634

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-
654635
FuncDecl *ASTContext::getPlusFunctionOnRangeReplaceableCollection() const {
655636
if (getImpl().PlusFunctionOnRangeReplaceableCollection) {
656637
return getImpl().PlusFunctionOnRangeReplaceableCollection;
@@ -707,10 +688,19 @@ FuncDecl *ASTContext::getPlusFunctionOnString() const {
707688

708689
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS) \
709690
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; \
714704
}
715705
#include "swift/AST/KnownStdlibTypes.def"
716706

0 commit comments

Comments
 (0)