@@ -1526,30 +1526,35 @@ AnyFunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
15261526// / that declared \p type. This is useful for code completion so we can match
15271527// / the types we do know instead of bailing out completely because \p type
15281528// / contains an error type.
1529- static Type replaceParamErrorTypeByPlaceholder (Type type, ValueDecl *value) {
1529+ static Type replaceParamErrorTypeByPlaceholder (Type type, ValueDecl *value, bool hasAppliedSelf ) {
15301530 if (!type->is <AnyFunctionType>() || !isa<AbstractFunctionDecl>(value)) {
15311531 return type;
15321532 }
15331533 auto funcType = type->castTo <AnyFunctionType>();
15341534 auto funcDecl = cast<AbstractFunctionDecl>(value);
15351535
1536- auto declParams = funcDecl->getParameters ();
1536+ SmallVector<ParamDecl *> declParams;
1537+ if (hasAppliedSelf) {
1538+ declParams.append (funcDecl->getParameters ()->begin (), funcDecl->getParameters ()->end ());
1539+ } else {
1540+ declParams.push_back (funcDecl->getImplicitSelfDecl ());
1541+ }
15371542 auto typeParams = funcType->getParams ();
1538- assert (declParams-> size () == typeParams.size ());
1543+ assert (declParams. size () == typeParams.size ());
15391544 SmallVector<AnyFunctionType::Param, 4 > newParams;
1540- newParams.reserve (declParams-> size ());
1545+ newParams.reserve (declParams. size ());
15411546 for (auto i : indices (typeParams)) {
15421547 AnyFunctionType::Param param = typeParams[i];
15431548 if (param.getPlainType ()->is <ErrorType>()) {
1544- auto paramDecl = declParams-> get (i) ;
1549+ auto paramDecl = declParams[i] ;
15451550 auto placeholder =
15461551 PlaceholderType::get (paramDecl->getASTContext (), paramDecl);
15471552 newParams.push_back (param.withType (placeholder));
15481553 } else {
15491554 newParams.push_back (param);
15501555 }
15511556 }
1552- assert (newParams.size () == declParams-> size ());
1557+ assert (newParams.size () == declParams. size ());
15531558 return FunctionType::get (newParams, funcType->getResult ());
15541559}
15551560
@@ -1620,7 +1625,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
16201625 if (isForCodeCompletion () && openedType->hasError ()) {
16211626 // In code completion, replace error types by placeholder types so we can
16221627 // match the types we know instead of bailing out completely.
1623- openedType = replaceParamErrorTypeByPlaceholder (openedType, value);
1628+ openedType = replaceParamErrorTypeByPlaceholder (openedType, value, /* hasAppliedSelf= */ true );
16241629 }
16251630
16261631 // If we opened up any type variables, record the replacements.
@@ -2288,7 +2293,7 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
22882293 if (isForCodeCompletion () && type->hasError ()) {
22892294 // In code completion, replace error types by placeholder types so we can
22902295 // match the types we know instead of bailing out completely.
2291- type = replaceParamErrorTypeByPlaceholder (type, value);
2296+ type = replaceParamErrorTypeByPlaceholder (type, value, hasAppliedSelf );
22922297 }
22932298
22942299 return type;
0 commit comments