Allow partial applications of mutating methods in @noescape contexts

struct MyStruct {
    var count = 0
    
    mutating func add(amount: Int) {
        count += amount
    }
}

var myStruct = MyStruct()
[1, 2, 3, 4].forEach(myStruct.add)

This code currently doesn’t compile because myStruct.add is a partial application of a mutating method, which is forbidden. However, in my understanding, this cannot cause problems inside forEach because its body is marked @noescape. So, could we allow partial applications of mutating methods in @noescape contexts?

1 Like