[Sema] Add getDeclOrNull to OverloadChoice

This helps clean up a bunch of call sites.
This commit is contained in:
Hamish Knight
2019-05-15 21:55:09 +01:00
committed by Hamish Knight
parent 63df26a498
commit 8aa7401ba5
7 changed files with 25 additions and 40 deletions

View File

@@ -859,8 +859,7 @@ getCalleeDeclAndArgs(ConstraintSystem &cs,
hasTrailingClosure);
// If there's a declaration, return it.
if (choice->isDecl()) {
auto decl = choice->getDecl();
if (auto *decl = choice->getDeclOrNull()) {
bool hasCurriedSelf = false;
if (decl->getDeclContext()->isTypeContext()) {
if (auto function = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -4475,9 +4474,7 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
Optional<MemberLookupResult::UnviableReason> reason = None) {
// Not all of the choices handled here are going
// to refer to a declaration.
if (choice.isDecl()) {
auto *decl = choice.getDecl();
if (auto *decl = choice.getDeclOrNull()) {
if (auto *CD = dyn_cast<ConstructorDecl>(decl)) {
if (auto *fix = validateInitializerRef(cs, CD, locator))
return fix;