Skip to content

Commit 5239edf

Browse files
committed
[TypeChecker] Add a test-case for rdar://problem/46497155
1 parent 9ecc0ab commit 5239edf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol P {
4+
func isEqual(_ other: P) -> Bool
5+
}
6+
7+
struct A {
8+
var value: P? = nil
9+
}
10+
11+
struct B {
12+
func foo() throws -> A {}
13+
}
14+
15+
struct E {
16+
func getB(_ flag: inout Bool) throws -> B {
17+
return B()
18+
}
19+
}
20+
21+
func foo(arr: [E], other: P) -> Bool {
22+
return arr.compactMap { i in
23+
// expected-error@-1 {{unable to infer complex closure return type; add explicit type to disambiguate}} {{29-29=-> B? }}
24+
var flag = false
25+
return try? i.getB(&flag)
26+
}.compactMap { u -> P? in
27+
guard let a = try? u.foo() else { return nil }
28+
return a.value!
29+
}.contains {
30+
$0.isEqual(other)
31+
}
32+
}

0 commit comments

Comments
 (0)