Calling super methods safely #455
Labels
A-framework
Affects the framework crates and the translator for them
A-objc2
Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates
enhancement
New feature or request
question
Further information is requested
Milestone
Calling a super method is (with the below restrictions) as safe as calling regular methods.
Since doing so is a common requirement, e.g. in initializers, or when subclassing e.g.
NSView
, we should find a way so that the user can easily do so.Requirements that I know of so far:
NSResponder
's methods from a subclass ofNSView
could potentially lead to UB, ifNSView
was implemented in a certain way.The main problem with this is that it effectively doubles the amount of methods that we have to generate, the codegen is different for each. Though maybe with #448, that will be less of a problem?
If we had inherent traits, or something like it, then it would perhaps be easier, since we could make the implementation on a trait instead.
Related: Internally, we can consider getting rid of
send_message_super
, by providing astruct Super<T: MessageReceiver> { obj: T, cls: &'static Class }
that implementsMessageReceiver::send_message
by callingobjc_msgSendSuper
instead.Related:
super
inmsg_send_id!
#173declare_class!
: Safer initializers #438The text was updated successfully, but these errors were encountered: