My Swift globals are not getting deinitialized.
class Person {
let name: String
init(name: String) {
self.name = name
println("\(name) is being initialized")
}
deinit {
println("\(name) is being deinitialized")
}
}
func local() {
let person = Person(name: "Local")
}
local()
var personp: Person? = Person(name: "Optional Global")
personp = nil
var person = Person(name: "Global")
I am running this in a standalone binary (because apparently the playground has issues with deinit) with optimizations disabled, using Xcode6-Beta3:
> xcrun swift -O0 arc.swift && ./arc
Local is being initialized
Local is being deinitialized
Optional Global is being initialized
Optional Global is being deinitialized
Global is being initialized
Note the missing Global is being deinitialized.
I can't even figure out if this is expected behaviour or a bug, so if it is the former then references to the relevant legalese will be appreciated.