@@ -286,15 +286,19 @@ pub trait MessageArguments: EncodeArguments {
286
286
/// This method is the primitive used when sending messages and should not
287
287
/// be called directly; instead, use the `msg_send!` macro or, in cases
288
288
/// with a dynamic selector, the [`MessageReceiver::send_message`] method.
289
- unsafe fn invoke < R > ( imp : Imp , obj : * mut Object , sel : Sel , args : Self ) -> R ;
289
+ unsafe fn invoke < R : Encode > ( imp : Imp , obj : * mut Object , sel : Sel , args : Self ) -> R ;
290
290
}
291
291
292
292
macro_rules! message_args_impl {
293
293
( $( $a: ident : $t: ident) ,* ) => (
294
294
impl <$( $t: Encode ) ,* > MessageArguments for ( $( $t, ) * ) {
295
- unsafe fn invoke<R >( imp: Imp , obj: * mut Object , sel: Sel , ( $( $a, ) * ) : Self ) -> R {
296
- let imp: unsafe extern fn ( * mut Object , Sel $( , $t) * ) -> R =
297
- mem:: transmute( imp) ;
295
+ #[ inline]
296
+ unsafe fn invoke<R : Encode >( imp: Imp , obj: * mut Object , sel: Sel , ( $( $a, ) * ) : Self ) -> R {
297
+ // The imp must be cast to the appropriate function pointer
298
+ // type before being called; the msgSend functions are not
299
+ // parametric, but instead "trampolines" to the actual
300
+ // method implementations.
301
+ let imp: unsafe extern "C" fn ( * mut Object , Sel $( , $t) * ) -> R = mem:: transmute( imp) ;
298
302
imp( obj, sel $( , $a) * )
299
303
}
300
304
}
0 commit comments