mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
@@ -196,6 +196,9 @@ struct ASTContext::Implementation {
|
||||
/// The declaration of '+' function for two String.
|
||||
FuncDecl *PlusFunctionOnString = nullptr;
|
||||
|
||||
/// The declaration of 'Sequence.makeIterator()'.
|
||||
FuncDecl *MakeIterator = nullptr;
|
||||
|
||||
/// The declaration of Swift.Optional<T>.Some.
|
||||
EnumElementDecl *OptionalSomeDecl = nullptr;
|
||||
|
||||
@@ -712,6 +715,31 @@ FuncDecl *ASTContext::getPlusFunctionOnString() const {
|
||||
return getImpl().PlusFunctionOnString;
|
||||
}
|
||||
|
||||
FuncDecl *ASTContext::getSequenceMakeIterator() const {
|
||||
if (getImpl().MakeIterator) {
|
||||
return getImpl().MakeIterator;
|
||||
}
|
||||
|
||||
auto proto = getProtocol(KnownProtocolKind::Sequence);
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
|
||||
for (auto result : proto->lookupDirect(Id_makeIterator)) {
|
||||
if (result->getDeclContext() != proto)
|
||||
continue;
|
||||
|
||||
if (auto func = dyn_cast<FuncDecl>(result)) {
|
||||
if (func->getParameters()->size() != 0)
|
||||
continue;
|
||||
|
||||
getImpl().MakeIterator = func;
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS) \
|
||||
DECL_CLASS *ASTContext::get##NAME##Decl() const { \
|
||||
if (getImpl().NAME##Decl) \
|
||||
|
||||
Reference in New Issue
Block a user