[CodeCompletion] Address Argyrios' and Ben's comments.

Swift SVN r30772
This commit is contained in:
Xi Ge
2015-07-29 18:01:40 +00:00
parent 70ea919bd2
commit 0743f07150

View File

@@ -697,29 +697,24 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
SmallVector<StringRef, 3> ParsedKeywords; SmallVector<StringRef, 3> ParsedKeywords;
void addSuperKeyword(CodeCompletionResultSink &Sink) { void addSuperKeyword(CodeCompletionResultSink &Sink) {
auto *D = CurDeclContext; auto *D = CurDeclContext->getInnermostTypeContext();
for (;D && !D->isNominalTypeOrNominalTypeExtensionContext();
D = D->getParent());
if (!D) if (!D)
return; return;
Type DT = D->isNominalTypeOrNominalTypeExtensionContext()->getDeclaredType(); Type DT = D->getDeclaredTypeInContext();
if (DT.isNull() || DT->is<ErrorType>()) if (DT.isNull() || DT->is<ErrorType>())
return; return;
OwnedResolver TypeResolver(createLazyResolver(CurDeclContext->getASTContext())); OwnedResolver TypeResolver(createLazyResolver(CurDeclContext->getASTContext()));
Type ST = DT->getSuperclass(TypeResolver.get()); Type ST = DT->getSuperclass(TypeResolver.get());
if (ST.isNull() || ST->is<ErrorType>()) if (ST.isNull() || ST->is<ErrorType>())
return; return;
auto Nominal = ST->getNominalOrBoundGenericNominal(); if (ST->getNominalOrBoundGenericNominal()) {
if (Nominal) {
CodeCompletionResultBuilder Builder(Sink, CodeCompletionResultBuilder Builder(Sink,
CodeCompletionResult::ResultKind::Keyword, CodeCompletionResult::ResultKind::Keyword,
SemanticContextKind::None); SemanticContextKind::None);
Builder.addTextChunk("super"); Builder.addTextChunk("super");
ST = ST->getReferenceStorageReferent(); ST = ST->getReferenceStorageReferent();
if (ST->isVoid()) assert(!ST->isVoid() && "Cannot get type name.");
Builder.addTypeAnnotation("Void"); Builder.addTypeAnnotation(ST.getString());
else
Builder.addTypeAnnotation(ST.getString());
} }
} }