| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 
 | // RUN: %target-swift-frontend -typecheck -verify -swift-version 4 %s
protocol P {}
struct Foo {
  mutating func boom() {}
}
let x = Foo.boom // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}}
var y = Foo()
let z0 = y.boom // expected-error{{cannot reference 'mutating' method as function value}}
let z1 = Foo.boom(&y) // expected-error{{cannot reference 'mutating' method as function value}}
func fromLocalContext() -> (inout Foo) -> () -> () {
  return Foo.boom // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}}
}
func fromLocalContext2(x: inout Foo, y: Bool) -> () -> () {
  if y {
    return x.boom // expected-error{{cannot reference 'mutating' method as function value}}
  } else {
    return Foo.boom(&x) // expected-error{{cannot reference 'mutating' method as function value}}
  }
}
func bar() -> P.Type { fatalError() }
func bar() -> Foo.Type { fatalError() }
_ = bar().boom       // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}}
_ = bar().boom(&y)   // expected-error{{cannot reference 'mutating' method as function value}}
_ = bar().boom(&y)() // expected-error{{cannot reference 'mutating' method as function value}}
func foo(_ foo: Foo.Type) {
  _ = foo.boom       // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}}
  _ = foo.boom(&y)   // expected-error{{cannot reference 'mutating' method as function value}}
  _ = foo.boom(&y)() // expected-error{{cannot reference 'mutating' method as function value}}
}
 |