Skip to content

Commit 62c4036

Browse files
authored
Add a regression test for SR-9624 (#21741)
It got fixed somewhere along the way in Swift 5.
1 parent 91eec24 commit 62c4036

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-run-simple-swift | %FileCheck %s
2+
// REQUIRES: executable_test
3+
4+
protocol P {
5+
associatedtype T
6+
func foo(t: inout T)
7+
}
8+
struct S: P {
9+
func foo(t: inout () -> Void) {
10+
t()
11+
t = { print("new") }
12+
}
13+
}
14+
15+
func doTheFoo<SomeP: P>(_ p: SomeP, _ value: SomeP.T) -> SomeP.T {
16+
var mutableValue = value
17+
p.foo(t: &mutableValue)
18+
return mutableValue
19+
}
20+
21+
print("START")
22+
let newClosure = doTheFoo(S(), { print("old") })
23+
newClosure()
24+
print("DONE")
25+
26+
// CHECK: START
27+
// CHECK-NEXT: old
28+
// CHECK-NEXT: new
29+
// CHECK-NEXT: DONE

0 commit comments

Comments
 (0)