The following code example doesn't compile because of the circular reference. Except if you uncomment the line that uses the weak self. It's still an invalid circular reference, but all of a sudden the compiler accepts it. Happens with Xcode 12.5 and 13 Beta 1.
class Flupp {
init() {
print("Flupp!")
}
deinit {
print("Deflupp!")
}
}
struct Boing {
var boing: () -> Void
}
class Schnuck {
init() {
var boing = Boing { [weak self] in
print(boing)
// <--- Uncomment this to make it compile
// guard let self = self else { return }
}
}
}