Files
swift-mirror/validation-test/execution/sr9624.swift
Jordan Rose 62c4036f69 Add a regression test for SR-9624 (#21741)
It got fixed somewhere along the way in Swift 5.
2019-01-09 11:06:31 -08:00

30 lines
535 B
Swift

// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test
protocol P {
associatedtype T
func foo(t: inout T)
}
struct S: P {
func foo(t: inout () -> Void) {
t()
t = { print("new") }
}
}
func doTheFoo<SomeP: P>(_ p: SomeP, _ value: SomeP.T) -> SomeP.T {
var mutableValue = value
p.foo(t: &mutableValue)
return mutableValue
}
print("START")
let newClosure = doTheFoo(S(), { print("old") })
newClosure()
print("DONE")
// CHECK: START
// CHECK-NEXT: old
// CHECK-NEXT: new
// CHECK-NEXT: DONE