IDE: Simplify/Refactor some code that collects the default implementations in protocol extensions. NFC (#8381)

This commit is contained in:
Xi Ge
2017-03-27 18:14:45 -07:00
committed by GitHub
parent db7c768711
commit 5663f6799f
3 changed files with 52 additions and 20 deletions

View File

@@ -54,14 +54,14 @@ using namespace swift;
struct SynthesizedExtensionAnalyzer::Implementation {
static bool isMemberFavored(const NominalTypeDecl* Target, const Decl* D) {
DeclContext* DC = Target->getDeclContext();
DeclContext* DC = Target->getInnermostDeclContext();
Type BaseTy = Target->getDeclaredTypeInContext();
const FuncDecl *FD = dyn_cast<FuncDecl>(D);
if (!FD)
return true;
ResolveMemberResult Result = resolveValueMember(*DC, BaseTy,
FD->getEffectiveFullName());
return !(Result && Result.Favored != D);
return !(Result.hasBestOverload() && Result.getBestOverload() != D);
}
static bool isExtensionFavored(const NominalTypeDecl* Target,
@@ -1647,8 +1647,9 @@ static bool shouldPrintAsFavorable(const Decl *D, PrintOptions &Options) {
if (!FD)
return true;
ResolveMemberResult Result = resolveValueMember(*Target->getDeclContext(),
BaseTy, FD->getEffectiveFullName());
return !(Result && Result.Favored != D);
BaseTy,
FD->getEffectiveFullName());
return !(Result.hasBestOverload() && Result.getBestOverload() != D);
}
bool swift::shouldPrint(const Decl *D, PrintOptions &Options) {