Skip to content

Commit 3d0906f

Browse files
authored
Merge pull request #63516 from ahoppen/ahoppen/5.8-look-through-optional
[5.8][CodeCompletion] Look through optional when determining the function type of a called overload
2 parents 3ec56ba + 2f5a294 commit 3d0906f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/IDE/ArgumentCompletion.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ bool ArgumentTypeCheckCompletionCallback::addPossibleParams(
3737
}
3838

3939
ArrayRef<AnyFunctionType::Param> ParamsToPass =
40-
Res.FuncTy->getAs<AnyFunctionType>()->getParams();
40+
Res.FuncTy->lookThroughAllOptionalTypes()
41+
->getAs<AnyFunctionType>()
42+
->getParams();
4143

4244
ParameterList *PL = nullptr;
4345
if (Res.FuncD) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
3+
4+
func foo(_ x: ((_ x: Int, _ y: Int) -> Void)?) {
5+
x?(1, #^OPTIONAL_PARAMETER^#)
6+
// OPTIONAL_PARAMETER: Begin completions
7+
// OPTIONAL_PARAMETER-DAG: Literal[Integer]/None/TypeRelation[Convertible]: 0[#Int#]; name=0
8+
// OPTIONAL_PARAMETER: End completions
9+
}

0 commit comments

Comments
 (0)