IDE: Always use the right DeclContext

We have a hack where we use the ParsedDecl as the DeclContext,
to handle completion during function signature parsing, which
happens before the FuncDecl has been created.

While fixing this properly would require a bigger change to the
parser and AST, for now we just check if the ParsedDecl is a
child context of CurDeclContext, and only use it then.
This commit is contained in:
Slava Pestov
2017-09-19 21:51:14 -07:00
parent bf381cacab
commit ab8677faab
3 changed files with 7 additions and 6 deletions

View File

@@ -5121,8 +5121,10 @@ void CodeCompletionCallbacksImpl::doneParsing() {
if (ParsedDecl && !typecheckParsedDecl())
return;
if (auto *DC = dyn_cast_or_null<DeclContext>(ParsedDecl))
CurDeclContext = DC;
if (auto *DC = dyn_cast_or_null<DeclContext>(ParsedDecl)) {
if (DC->isChildContextOf(CurDeclContext))
CurDeclContext = DC;
}
Optional<Type> ExprType;
ConcreteDeclRef ReferencedDecl = nullptr;