mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Type Checker] Introduce a request for “overridden declarations”.
Introduce a new request kind to capture the computation of the set of overridden declarations of a given declaration, eliminating the stateful “setOverriddenDecls()” calls from the type checker.
This commit is contained in:
@@ -2022,6 +2022,18 @@ CanType ValueDecl::getOverloadSignatureType() const {
|
||||
return CanType();
|
||||
}
|
||||
|
||||
SmallVector<ValueDecl *, 1> ValueDecl::getOverriddenDecls() const {
|
||||
ASTContext &ctx = getASTContext();
|
||||
return ctx.evaluator(OverriddenDeclsRequest{const_cast<ValueDecl *>(this)});
|
||||
}
|
||||
|
||||
void ValueDecl::setOverriddenDecls(ArrayRef<ValueDecl *> overridden) {
|
||||
SmallVector<ValueDecl *, 1> overriddenVec(overridden.begin(),
|
||||
overridden.end());
|
||||
OverriddenDeclsRequest request{const_cast<ValueDecl *>(this)};
|
||||
request.cacheResult(overriddenVec);
|
||||
}
|
||||
|
||||
bool ValueDecl::isObjC() const {
|
||||
if (LazySemanticInfo.isObjCComputed)
|
||||
return LazySemanticInfo.isObjC;
|
||||
@@ -2866,6 +2878,15 @@ SourceRange AssociatedTypeDecl::getSourceRange() const {
|
||||
return SourceRange(KeywordLoc, endLoc);
|
||||
}
|
||||
|
||||
SmallVector<AssociatedTypeDecl *, 1>
|
||||
AssociatedTypeDecl::getOverriddenDecls() const {
|
||||
SmallVector<AssociatedTypeDecl *, 1> assocTypes;
|
||||
for (auto decl : AbstractTypeParamDecl::getOverriddenDecls()) {
|
||||
assocTypes.push_back(cast<AssociatedTypeDecl>(decl));
|
||||
}
|
||||
return assocTypes;
|
||||
}
|
||||
|
||||
AssociatedTypeDecl *AssociatedTypeDecl::getAssociatedTypeAnchor() const {
|
||||
auto overridden = getOverriddenDecls();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user