@@ -1523,30 +1523,35 @@ AnyFunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
1523
1523
// / that declared \p type. This is useful for code completion so we can match
1524
1524
// / the types we do know instead of bailing out completely because \p type
1525
1525
// / contains an error type.
1526
- static Type replaceParamErrorTypeByPlaceholder (Type type, ValueDecl *value) {
1526
+ static Type replaceParamErrorTypeByPlaceholder (Type type, ValueDecl *value, bool hasAppliedSelf ) {
1527
1527
if (!type->is <AnyFunctionType>() || !isa<AbstractFunctionDecl>(value)) {
1528
1528
return type;
1529
1529
}
1530
1530
auto funcType = type->castTo <AnyFunctionType>();
1531
1531
auto funcDecl = cast<AbstractFunctionDecl>(value);
1532
1532
1533
- auto declParams = funcDecl->getParameters ();
1533
+ SmallVector<ParamDecl *> declParams;
1534
+ if (hasAppliedSelf) {
1535
+ declParams.append (funcDecl->getParameters ()->begin (), funcDecl->getParameters ()->end ());
1536
+ } else {
1537
+ declParams.push_back (funcDecl->getImplicitSelfDecl ());
1538
+ }
1534
1539
auto typeParams = funcType->getParams ();
1535
- assert (declParams-> size () == typeParams.size ());
1540
+ assert (declParams. size () == typeParams.size ());
1536
1541
SmallVector<AnyFunctionType::Param, 4 > newParams;
1537
- newParams.reserve (declParams-> size ());
1542
+ newParams.reserve (declParams. size ());
1538
1543
for (auto i : indices (typeParams)) {
1539
1544
AnyFunctionType::Param param = typeParams[i];
1540
1545
if (param.getPlainType ()->is <ErrorType>()) {
1541
- auto paramDecl = declParams-> get (i) ;
1546
+ auto paramDecl = declParams[i] ;
1542
1547
auto placeholder =
1543
1548
PlaceholderType::get (paramDecl->getASTContext (), paramDecl);
1544
1549
newParams.push_back (param.withType (placeholder));
1545
1550
} else {
1546
1551
newParams.push_back (param);
1547
1552
}
1548
1553
}
1549
- assert (newParams.size () == declParams-> size ());
1554
+ assert (newParams.size () == declParams. size ());
1550
1555
return FunctionType::get (newParams, funcType->getResult ());
1551
1556
}
1552
1557
@@ -1617,7 +1622,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
1617
1622
if (isForCodeCompletion () && openedType->hasError ()) {
1618
1623
// In code completion, replace error types by placeholder types so we can
1619
1624
// match the types we know instead of bailing out completely.
1620
- openedType = replaceParamErrorTypeByPlaceholder (openedType, value);
1625
+ openedType = replaceParamErrorTypeByPlaceholder (openedType, value, /* hasAppliedSelf= */ true );
1621
1626
}
1622
1627
1623
1628
// If we opened up any type variables, record the replacements.
@@ -2285,7 +2290,7 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
2285
2290
if (isForCodeCompletion () && type->hasError ()) {
2286
2291
// In code completion, replace error types by placeholder types so we can
2287
2292
// match the types we know instead of bailing out completely.
2288
- type = replaceParamErrorTypeByPlaceholder (type, value);
2293
+ type = replaceParamErrorTypeByPlaceholder (type, value, hasAppliedSelf );
2289
2294
}
2290
2295
2291
2296
return type;
0 commit comments