From 39d7ee2d463116dd1452571ea1ce86ccc3aaedcc Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 25 Aug 2017 22:29:23 -0700 Subject: [PATCH] Sema: Fix diagnostics when 'self' in a convenience init has DynamicSelfType We don't want to print 'Self' here; the actual concrete type is more useful. NFC for now, but becomes important once a subsequent patch gives 'self' a DynamicSelfType in convenience initializers. --- lib/Sema/CSDiag.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Sema/CSDiag.cpp b/lib/Sema/CSDiag.cpp index a347f971aab..dda47122265 100644 --- a/lib/Sema/CSDiag.cpp +++ b/lib/Sema/CSDiag.cpp @@ -1540,8 +1540,8 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn, auto decl = declRefExpr->getDecl(); candidates.push_back({ decl, getCalleeLevel(decl) }); - if (auto fTy = decl->getInterfaceType()->getAs()) - declName = fTy->getInput()->getRValueInstanceType()->getString()+".init"; + if (auto selfTy = decl->getDeclContext()->getSelfInterfaceType()) + declName = selfTy.getString() + ".init"; else declName = "init"; return; @@ -1657,7 +1657,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn, if (UDE->getName().getBaseName() == CS.TC.Context.Id_init) { auto selfTy = CS.getType(UDE->getBase())->getWithoutSpecifierType(); if (!selfTy->hasTypeVariable()) - declName = selfTy.getString() + "." + declName; + declName = selfTy->eraseDynamicSelfType().getString() + "." + declName; } // Otherwise, look for a disjunction constraint explaining what the set is.