Code completion: complete declarations that are required for declared protocol

conformances

rdar://16539292

This is a hack in visible decl lookup.  The general solution that would also
improve type checker errors would be to make the type checker keep these broken
conformances and syntethize missing declarations to make downstream code type
check.  For that, see:

<rdar://problem/16723339> [QoI] Type checker should not be dropping protocol
conformances explicitly spelled in the source


Swift SVN r16818
This commit is contained in:
Dmitri Hrybenko
2014-04-25 14:03:39 +00:00
parent 35c587aadf
commit 3ee34efee4
3 changed files with 46 additions and 5 deletions

View File

@@ -927,6 +927,7 @@ public:
return SemanticContextKind::ExpressionSpecific;
return SemanticContextKind::CurrentNominal;
case DeclVisibilityKind::MemberOfProtocolImplementedByCurrentNominal:
case DeclVisibilityKind::MemberOfSuper:
return SemanticContextKind::Super;
@@ -1774,7 +1775,7 @@ public:
TypeResolver(createLazyResolver(Ctx)),
CurrDeclContext(CurrDeclContext) {}
void addMethodOverride(const FuncDecl *FD) {
void addMethodOverride(const FuncDecl *FD, DeclVisibilityKind Reason) {
CodeCompletionResultBuilder Builder(
Sink,
CodeCompletionResult::ResultKind::Declaration,
@@ -1784,7 +1785,8 @@ public:
llvm::SmallString<256> DeclStr;
{
llvm::raw_svector_ostream OS(DeclStr);
OS << "override ";
if (Reason == DeclVisibilityKind::MemberOfSuper)
OS << "override ";
PrintOptions Options;
Options.FunctionDefinitions = false;
Options.PrintDefaultParameterPlaceholder = false;
@@ -1813,7 +1815,7 @@ public:
if (FD->isAccessor())
return;
addMethodOverride(FD);
addMethodOverride(FD, Reason);
return;
}
}