class Cat { init() { print("Cat init(\(ObjectIdentifier(self))") } deinit { print("Cat deinit(\(ObjectIdentifier(self))") } var catProp: Cat { get { return Cat() } set { print("catProp setter: \(ObjectIdentifier(self))") } } } func f1(_ x: inout Cat) { print("f1 begin") x = Cat() print("f1 end") } func main() { print("b") f1(&Cat().catProp) print("c") } main()
b Cat init(ObjectIdentifier(0x00007fd899434f90) Cat init(ObjectIdentifier(0x00007fd899424d70) f1 begin Cat init(ObjectIdentifier(0x00007fd899434d50) Cat deinit(ObjectIdentifier(0x00007fd899424d70) f1 end catProp setter: ObjectIdentifier(0x00007fd899434f90) Cat deinit(ObjectIdentifier(0x00007fd899434d50) Cat deinit(ObjectIdentifier(0x00007fd899434f90) c