mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal type declaration that the extension declaration extends. Move most of the existing callers of the callers to getExtendedType() over to getExtendedNominal(), because they don’t need the full type information. ExtensionDecl::getExtendedNominal() is itself not very interesting yet, because it depends on getExtendedType().
This commit is contained in:
@@ -114,15 +114,13 @@ class AnnotatingPrinter : public StreamPrinter {
|
||||
const auto *ED = dyn_cast<ExtensionDecl>(D);
|
||||
if (!ED)
|
||||
return;
|
||||
if (ED->getExtendedType()) {
|
||||
if (auto NTD = ED->getExtendedType()->getAnyNominal()) {
|
||||
if (auto *PD = dyn_cast<ProtocolDecl>(NTD)) {
|
||||
auto Pair = AllDefaultMaps.insert({PD, DefaultImplementMap()});
|
||||
DefaultMapToUse = &Pair.first->getSecond();
|
||||
if (Pair.second) {
|
||||
swift::collectDefaultImplementationForProtocolMembers(PD,
|
||||
Pair.first->getSecond());
|
||||
}
|
||||
if (auto NTD = ED->getExtendedNominal()) {
|
||||
if (auto *PD = dyn_cast<ProtocolDecl>(NTD)) {
|
||||
auto Pair = AllDefaultMaps.insert({PD, DefaultImplementMap()});
|
||||
DefaultMapToUse = &Pair.first->getSecond();
|
||||
if (Pair.second) {
|
||||
swift::collectDefaultImplementationForProtocolMembers(PD,
|
||||
Pair.first->getSecond());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,8 +372,8 @@ static bool initDocEntityInfo(const Decl *D,
|
||||
assert(DocRef.find(Open) != StringRef::npos);
|
||||
auto FirstPart = DocRef.substr(0, DocRef.find(Open) + (Open).size());
|
||||
auto SecondPart = DocRef.substr(FirstPart.size());
|
||||
auto ExtendedName = ((const ExtensionDecl*)D)->getExtendedType()->
|
||||
getAnyNominal()->getName().str();
|
||||
auto ExtendedName = ((const ExtensionDecl*)D)->getExtendedNominal()
|
||||
->getName().str();
|
||||
assert(SecondPart.startswith(ExtendedName));
|
||||
SecondPart = SecondPart.substr(ExtendedName.size());
|
||||
llvm::SmallString<128> UpdatedDocBuffer;
|
||||
|
||||
Reference in New Issue
Block a user