Skip to content

Commit

Permalink
Properly emit protocol objects with multiple protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Nov 25, 2024
1 parent 87dcf25 commit 63d42bf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions crates/header-translator/src/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,14 +1416,18 @@ impl Ty {
Self::GenericParam { name } => write!(f, "{name}"),
Self::AnyObject { protocols } => match &**protocols {
[] => write!(f, "AnyObject"),
[decl] => write!(f, "ProtocolObject<dyn {}>", decl.id.path()),
// TODO: Handle this better
[first, rest @ ..] => {
write!(f, "AnyObject /* {}", first.id.path())?;
for protocol in rest {
write!(f, "+ {}", protocol.id.path())?;
protocols => {
write!(f, "ProtocolObject<dyn ")?;

let mut iter = protocols.iter();
let protocol = iter.next().unwrap();
write!(f, "{}", protocol.path())?;

for protocol in iter {
write!(f, " + {}", protocol.path())?;
}
write!(f, " */")?;

write!(f, ">")?;
Ok(())
}
},
Expand Down

0 comments on commit 63d42bf

Please sign in to comment.