mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The currying behavior of method references completely breaks in the face of `inout` semantics, even moreso with exclusivity enforcement, but we failed to diagnose these references in Swift 4 and previous versions. Raise a compatibility warning when these references are found in Swift 4 code, or error in Swift 5 and later. Simplify the partial application logic here slightly too now that standalone functions do not allow currying. Addresses rdar://problem/41361334 | SR-8074.
23 lines
757 B
Swift
23 lines
757 B
Swift
// RUN: %target-swift-frontend -typecheck -verify -swift-version 5 %s
|
|
|
|
struct Foo {
|
|
mutating func boom() {}
|
|
}
|
|
|
|
let x = Foo.boom // expected-error{{partial application of 'mutating' method}}
|
|
var y = Foo()
|
|
let z0 = y.boom // expected-error{{partial application of 'mutating' method}}
|
|
let z1 = Foo.boom(&y) // expected-error{{partial application of 'mutating' method}}
|
|
|
|
func fromLocalContext() -> (inout Foo) -> () -> () {
|
|
return Foo.boom // expected-error{{partial application of 'mutating' method}}
|
|
}
|
|
func fromLocalContext2(x: inout Foo, y: Bool) -> () -> () {
|
|
if y {
|
|
return x.boom // expected-error{{partial application of 'mutating' method}}
|
|
} else {
|
|
return Foo.boom(&x) // expected-error{{partial application of 'mutating' method}}
|
|
}
|
|
}
|
|
|