[CodeCompletion] Be lenient in callee analysis

Accept `getInterfaceType->hasError()` declarations. Even if the part of
the declaration has error, we still have chance to get context info from
the other part of it. For instance:

  func foo(x: Int, y: INt) { }
  foo(x: #^COMPLETE^#

We should resolve 'Int' as the context type even if parameter `y` is an
error type.
This commit is contained in:
Rintaro Ishizaki
2018-12-03 17:14:07 +09:00
parent 24265272fc
commit 337d53f217
2 changed files with 37 additions and 2 deletions

View File

@@ -4993,12 +4993,13 @@ void collectPossibleCalleesByQualifiedLookup(
Type declaredMemberType = VD->getInterfaceType();
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(VD))
if (AFD->getDeclContext()->isTypeContext())
declaredMemberType = AFD->getMethodInterfaceType();
declaredMemberType =
declaredMemberType->castTo<AnyFunctionType>()->getResult();
auto fnType =
baseTy->getTypeOfMember(DC.getParentModule(), VD, declaredMemberType);
if (!fnType || fnType->hasError())
if (!fnType)
continue;
if (auto *AFT = fnType->getAs<AnyFunctionType>()) {
candidates.emplace_back(AFT, VD);