import UIKit
import Combine
class SomeParentObject {
func openFunction() {
print("parentFunction")
}
}
final class SomeChildObject: SomeParentObject {
var cancelBag = Set<AnyCancellable>()
override func openFunction() {
print("childFunction")
}
func bind() {
Just("hello")
.sink(receiveValue: { [weak self] _ in
super.openFunction() // ERROR: "Using 'super' in a closure where 'self' is explicitly captured is not yet supported"
})
.store(in: &cancelBag)
}
}
I tried to find articles about this error, but I couldn't find one explaining why.
I wonder why such restriction was introduced in Swift.
Could anyone give me an explanation?
There's no deep fundamental reason why it has to be prohibited; It's an implementation limitation. Fixing it is a matter of ensuring that SuperExpr can represent this in the AST, and then possibly adjusting SILGen's lowering of super calls to take this possibility into account. It's doable without a huge effort; it's just one of those edge cases that hasn't been a priority yet.