Skip to content

Commit 597c0dc

Browse files
committed
[SourceKit] Fix crash when completing a parameter of an unapplied instance member reference
1 parent ed4dc1b commit 597c0dc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/IDE/ArgumentCompletion.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,18 @@ void ArgumentTypeCheckCompletionCallback::sawSolutionImpl(const Solution &S) {
236236
for (auto Idx : range(0, ParamsToPass.size())) {
237237
bool Optional = false;
238238
if (Info.ValueRef) {
239-
if (const ParamDecl *DeclParam = getParameterAt(Info.ValueRef, Idx)) {
239+
if (Info.ValueRef.getDecl()->isInstanceMember() &&
240+
!doesMemberRefApplyCurriedSelf(Info.BaseTy,
241+
Info.ValueRef.getDecl())) {
242+
// We are completing in an unapplied instance function, eg.
243+
// struct TestStatic {
244+
// func method() -> Void {}
245+
// }
246+
// TestStatic.method(#^STATIC^#)
247+
// The 'self' parameter is never optional, so don't enter the check
248+
// below (which always assumes that self has been applied).
249+
} else if (const ParamDecl *DeclParam =
250+
getParameterAt(Info.ValueRef, Idx)) {
240251
Optional |= DeclParam->isDefaultArgument();
241252
Optional |= DeclParam->getType()->is<PackExpansionType>();
242253
}

0 commit comments

Comments
 (0)