Skip to content

Implementing protocol methods with Id<_, _> return types #317

@ericmarkmartin

Description

@ericmarkmartin

Suppose we have a protocol P with method f(&self) -> Id<NSObject, Shared>. If we use declare_class! to implement this protocol for a new type...

declare_class!(
  struct C {
    // This is unrelated to this ticket but I can't figure out how to do empty structs in `declare_class`
    filler: u8
  }

  unsafe impl ConformsTo<P> for C {
    #[method(f)]
    fn f(&self) -> Id<NSObject, Shared> {
      unimplemented!()
    }
  }
)

We see

the trait Encodeis not implemented foricrate::objc2::rc::Id<NSObject, Shared>`

in the macro expansion because it generates

<Id<NSObject, Shared> as $crate::encode::EncodeConvert>::__into_inner({
  $crate::panicking::panic("not implemented")
})

And Id<_, _> doesn't implement EncodeConvert

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions