Skip to content

Support interfaces deriving from external traits (fixes #2430) - #2616

Merged
mhammond merged 1 commit into
mozilla:mainfrom
mhammond:push-qqppomtmywku
Aug 10, 2025
Merged

mhammond merged 1 commit into
mozilla:mainfrom
mhammond:push-qqppomtmywku

Conversation

@mhammond

@mhammond mhammond commented Aug 7, 2025

Copy link
Copy Markdown
Member

No description provided.

@mhammond
mhammond requested a review from a team as a code owner August 7, 2025 20:39
@mhammond
mhammond requested review from bendk and removed request for a team August 7, 2025 20:39

@bendk bendk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good to me. I had one concern about the module name, but I'm fine with merging this now and figuring that out later.

root.visit(|m: &Module| {
m.visit(|int: &Interface| {
if matches!(int.imp, ObjectImpl::Trait | ObjectImpl::CallbackTrait) {
known_traits.insert(int.name.clone(), m.name.to_owned());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this would fail if 2 modules defined traits with the same name.

I think that's okay for now, since we can't really do anything better. But what do you think about eventually adding a trait_module field in the metadata? I guess this would do what tr_module_name was trying to do before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this would fail if 2 modules defined traits with the same name.

yeah, I didn't think about that! So I made it fallible and made the restriction a little more obvious. It made me think too that it should be focused more on this specific issue, so renamed 'missing_typestotrait_types`.

But what do you think about eventually adding a trait_module field in the metadata? I guess this would do what tr_module_name was trying to do before.

Yeah, but I don't see a path to capturing that in the macros - certainly not the name, hence killing tr_module_name. I tried to use TYPE_ID_META but things went sideways due to the trait and I failed to work that out. It would be great if we could capture more metadata though and this could go away.

@mhammond
mhammond merged commit b0f16dc into mozilla:main Aug 10, 2025
@mhammond
mhammond deleted the push-qqppomtmywku branch August 10, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants