Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface support to check #3474

Merged
merged 9 commits into from
Dec 8, 2023
Merged

Conversation

josh11b
Copy link
Contributor

@josh11b josh11b commented Dec 7, 2023

Largely copied from the class code

Comment on lines 123 to 124
// TODO: do we need this for an interface?
context.args_type_info_stack().Push();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to create a witness table for interfaces? (I think we might -- even if we don't use them at runtime, I think we'll probably want a compile-time representation for them.) If we do, I think this stack would be the most consistent place to build one.

If not -- or not for now -- then we can remove this and the pop below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure, but if so I think it would be in a later change.

Comment on lines 91 to 96
if (auto kind = context.current_scope_kind()) {
if (*kind == SemIR::InterfaceDecl::Kind) {
// Both `default` and `final` allowed in an interface definition.
return;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could simplify this to:

Suggested change
if (auto kind = context.current_scope_kind()) {
if (*kind == SemIR::InterfaceDecl::Kind) {
// Both `default` and `final` allowed in an interface definition.
return;
}
}
if (context.GetCurrentScopeAs<SemIR::InterfaceDecl>()) {
// Both `default` and `final` allowed in an interface definition.
return;
}

(I think this ends up doing slightly more work, but I'd expect it to optimize to the same thing.)

Or if not that, then maybe we could add a CurrentScopeIs<Kind>? It looks like the other caller of current_scope_kind would also benefit from this change.

Copy link
Contributor Author

@josh11b josh11b Dec 8, 2023

Choose a reason for hiding this comment

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

Created and switched to CurrentScopeIs<Kind>.

@josh11b josh11b added this pull request to the merge queue Dec 8, 2023
Merged via the queue into carbon-language:trunk with commit 3b0923c Dec 8, 2023
6 checks passed
@josh11b josh11b deleted the iface branch December 8, 2023 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants