Skip to content

Commit 3476edf

Browse files
committed
---
yaml --- r: 349440 b: refs/heads/master-next c: 13e65c9 h: refs/heads/master
1 parent 5ea090b commit 3476edf

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: b025c3099de503660c74e8d9a19613f84564ee37
3+
refs/heads/master-next: 13e65c966a185b166f31353b5649f5001e1ee433
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/IDE/CodeCompletion.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,11 +1279,23 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
12791279
if (CheckKind == CompletionTypeCheckKind::Normal &&
12801280
ParsedExpr->getType() && !ParsedExpr->getType()->is<ErrorType>()) {
12811281
auto refDecl = ParsedExpr->getReferencedDecl();
1282+
auto exprTy = ParsedExpr->getType();
12821283
if (!refDecl) {
1283-
if (auto apply = dyn_cast<ApplyExpr>(ParsedExpr))
1284+
// FIXME: do this in the not-already-type-checked branch too?
1285+
if (auto *apply = dyn_cast<SelfApplyExpr>(ParsedExpr)) {
12841286
refDecl = apply->getFn()->getReferencedDecl();
1287+
} else if (auto *apply = dyn_cast<ApplyExpr>(ParsedExpr)) {
1288+
// If this is an IUO, use the underlying non-optional type instead
1289+
auto fnDecl = apply->getFn()->getReferencedDecl();
1290+
if (auto FD = fnDecl.getDecl()) {
1291+
if (FD->isImplicitlyUnwrappedOptional()) {
1292+
if (auto OT = exprTy->getOptionalObjectType())
1293+
exprTy = OT;
1294+
}
1295+
}
1296+
}
12851297
}
1286-
return std::make_pair(ParsedExpr->getType(), refDecl);
1298+
return std::make_pair(exprTy, refDecl);
12871299
}
12881300

12891301
ConcreteDeclRef ReferencedDecl = nullptr;

branches/master-next/test/IDE/complete_value_expr.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_ARRAY_LITERAL_2 | %FileCheck %s -check-prefix=SIMPLE_OBJECT_DOT
200200
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_DICTIONARY_LITERAL_1 | %FileCheck %s -check-prefix=SIMPLE_OBJECT_DOT
201201
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_DICTIONARY_LITERAL_2 | %FileCheck %s -check-prefix=SIMPLE_OBJECT_DOT
202+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE_CALL_RESULT | %FileCheck %s -check-prefix=COMPLETE_CALL_RESULT
202203

203204
// Test code completion of expressions that produce a value.
204205

@@ -2173,3 +2174,17 @@ func testInCollectionLiteral(value: SimpleStruct) {
21732174
value.#^IN_DICTIONARY_LITERAL_2^# : "test"
21742175
]
21752176
}
2177+
2178+
// rdar://problem/54047322
2179+
struct Resolver<T> {
2180+
func fulfill(_ value: T) {}
2181+
}
2182+
func wrapSuccess<T>(_ onSuccess: @escaping (T) -> Void) -> (T, Bool) -> Void {
2183+
fatalError()
2184+
}
2185+
func testWrapSuccess(promise: Int, seal: Resolver<Void>) {
2186+
wrapSuccess(seal.fulfill)#^COMPLETE_CALL_RESULT^#
2187+
// COMPLETE_CALL_RESULT: Begin completions
2188+
// COMPLETE_CALL_RESULT: Pattern/CurrModule: ({#Void#}, {#Bool#})[#Void#]; name=(Void, Bool)
2189+
// COMPLETE_CALL_RESULT: End completions
2190+
}

0 commit comments

Comments
 (0)