Skip to content

Commit 013333b

Browse files
committed
[CodeCompletion] Allow unresolved types in Callee analysis
struct Generic<T> { init(destination: T, isActive: Bool) { } } invalid { Generic(destination: true, #^COMPLETE^#) } In this case, since `invalid { ... }` cannot be type checked. `ExprContextAnalysis` tries to type check `Generic` alone which resolves to bound `Generic` type with an unresolved type. Previously, we used to give up the analysis when seeing unresolved type. That caused mis callee analyis. rdar://79092374
1 parent 21084b4 commit 013333b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ static bool collectPossibleCalleesForApply(
682682
fnType = *fnTypeOpt;
683683
}
684684

685-
if (!fnType || fnType->hasUnresolvedType() || fnType->hasError())
685+
if (!fnType || fnType->hasError())
686686
return false;
687687
fnType = fnType->getWithoutSpecifierType();
688688

test/IDE/complete_call_arg.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,3 +998,20 @@ struct Rdar77867723 {
998998
// OVERLOAD_LABEL2: End completions
999999
}
10001000
}
1001+
1002+
struct SR14737<T> {
1003+
init(arg1: T, arg2: Bool) {}
1004+
}
1005+
extension SR14737 where T == Int {
1006+
init(arg1: T, onlyInt: Bool) {}
1007+
}
1008+
func test_SR14737() {
1009+
invalidCallee {
1010+
SR14737(arg1: true, #^GENERIC_INIT_IN_INVALID^#)
1011+
// FIXME: 'onlyInt' shouldn't be offered because 'arg1' is Bool.
1012+
// GENERIC_INIT_IN_INVALID: Begin completions, 2 items
1013+
// GENERIC_INIT_IN_INVALID-DAG: Pattern/Local/Flair[ArgLabels]: {#arg2: Bool#}[#Bool#];
1014+
// GENERIC_INIT_IN_INVALID-DAG: Pattern/Local/Flair[ArgLabels]: {#onlyInt: Bool#}[#Bool#];
1015+
// GENERIC_INIT_IN_INVALID: End completions
1016+
}
1017+
}

0 commit comments

Comments
 (0)