Skip to content

Commit fb7a4e9

Browse files
committed
Generalize the closure work from yesterday, enough to fix:
rdar://17687826 - QoI: error message when reducing to an untyped dictionary isn't helpful
1 parent f1ea135 commit fb7a4e9

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6156,7 +6156,9 @@ diagnoseAmbiguousMultiStatementClosure(ClosureExpr *closure) {
61566156
return false;
61576157

61586158
auto closureType = closure->getType()->getAs<AnyFunctionType>();
6159-
if (!closureType || !isUnresolvedOrTypeVarType(closureType->getResult()))
6159+
if (!closureType ||
6160+
!(closureType->getResult()->hasUnresolvedType() ||
6161+
closureType->getResult()->hasTypeVariable()))
61606162
return false;
61616163

61626164
// Okay, we have a multi-statement closure expr that has no inferred result,

test/Constraints/subscript.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let _ = 1["1"] // expected-error {{ambiguous use of 'subscript'}}
7272

7373

7474
// rdar://17687826 - QoI: error message when reducing to an untyped dictionary isn't helpful
75-
let squares = [ 1, 2, 3 ].reduce([:]) { (dict, n) in // expected-error {{expression type '[_ : _]' is ambiguous without more context}}
75+
let squares = [ 1, 2, 3 ].reduce([:]) { (dict, n) in // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{51-51=-> [_ : _] }}
7676
var dict = dict
7777
dict[n] = n * n
7878
return dict

test/Constraints/tuple.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ extension r25271859 {
193193

194194
func f(a : r25271859<(Float, Int)>) {
195195
a.map { $0.0 }
196-
.andThen { _ in // expected-error {{generic parameter 'U' could not be inferred}}
196+
.andThen { _ in // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{18-18=-> r25271859<String> }}
197197
print("hello") // comment this out and it runs, leave any form of print in and it doesn't
198-
return Task<String>()
198+
return r25271859<String>()
199199
}
200200
}
201201

0 commit comments

Comments
 (0)