Skip to content

Commit 4eb7aaf

Browse files
committed
[Diagnostics] Add test-case for rdar://problem/32433193
1 parent 59f2bcd commit 4eb7aaf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/Constraints/closures.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,26 @@ r32432145 { _,_ in
532532
// rdar://problem/30106822 - Swift ignores type error in closure and presents a bogus error about the caller
533533
[1, 2].first { $0.foo = 3 }
534534
// expected-error@-1 {{value of type 'Int' has no member 'foo'}}
535+
536+
// rdar://problem/32433193, SR-5030 - Higher-order function diagnostic mentions the wrong contextual type conversion problem
537+
protocol A_SR_5030 {
538+
associatedtype Value
539+
func map<U>(_ t : @escaping (Self.Value) -> U) -> B_SR_5030<U>
540+
}
541+
542+
struct B_SR_5030<T> : A_SR_5030 {
543+
typealias Value = T
544+
func map<U>(_ t : @escaping (T) -> U) -> B_SR_5030<U> { fatalError() }
545+
}
546+
547+
func sr5030_exFalso<T>() -> T {
548+
fatalError()
549+
}
550+
551+
extension A_SR_5030 {
552+
func foo() -> B_SR_5030<Int> {
553+
let tt : B_SR_5030<Int> = sr5030_exFalso()
554+
return tt.map { x in (idx: x) }
555+
// expected-error@-1 {{cannot convert value of type '(idx: (Int))' to closure result type 'Int'}}
556+
}
557+
}

0 commit comments

Comments
 (0)