Skip to content

Commit 3f74263

Browse files
authored
Merge pull request #82910 from hamishknight/unbounded
2 parents f0c783a + e631a37 commit 3f74263

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/IDE/ArgumentCompletion.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ void ArgumentTypeCheckCompletionCallback::sawSolutionImpl(const Solution &S) {
148148
ExpectedCallType = ContextualType;
149149
}
150150
}
151-
if (ExpectedCallType && ExpectedCallType->hasUnresolvedType()) {
151+
if (ExpectedCallType &&
152+
(ExpectedCallType->hasUnresolvedType() ||
153+
ExpectedCallType->hasUnboundGenericType())) {
152154
ExpectedCallType = Type();
153155
}
154156

test/IDE/complete_call_arg.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,3 +1443,14 @@ struct NestedCallsWithoutClosingParen {
14431443
_ = (foo(#^IN_TUPLE?check=NESTED_CALL_WITHOUT_TYPE_RELATION^#, 1)
14441444
}
14451445
}
1446+
1447+
func testUnboundContextualType() {
1448+
struct S<T> {
1449+
func bar(x: Int) -> Self { self }
1450+
}
1451+
1452+
func foo(x: S<Int>) {
1453+
let _: S = x.bar(#^ARG_WITH_UNBOUND_CONTEXTUAL_TY^#
1454+
// ARG_WITH_UNBOUND_CONTEXTUAL_TY: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#x: Int#}[')'][#S<Int>#]; name=x:
1455+
}
1456+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"kind":"complete","signature":"swift::ide::CodeCompletionResultType::calculateTypeRelation(swift::ide::ExpectedTypeContext const*, swift::DeclContext const*, swift::ide::USRBasedTypeContext const*) const"}
2+
// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
3+
func b(a : Array<Int>) {
4+
let: Array = a.prefix( #^^#

0 commit comments

Comments
 (0)