// RUN: %target-run-simple-swift | %FileCheck %s // REQUIRES: executable_test // https://github.com/apple/swift/issues/52070 protocol P { associatedtype T func foo(t: inout T) } struct S: P { func foo(t: inout () -> Void) { t() t = { print("new") } } } func doTheFoo(_ 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