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 ExternDecl and ExternType for extern classes. #3893

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Apr 17, 2024

This expands extern handling for most cases.

@jonmeow jonmeow requested a review from zygoloid April 17, 2024 20:26
@jonmeow
Copy link
Contributor Author

jonmeow commented Apr 17, 2024

Depends on #3891

@jonmeow jonmeow force-pushed the extern-track branch 3 times, most recently from 8c6885a to 5ea115e Compare April 19, 2024 17:41
Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

Looks good. One potential concern, but if it is a real problem, it can be addressed in a separate PR.

Comment on lines +61 to +64
case CARBON_KIND(SemIR::ClassType class_type): {
prev_class_id = class_type.class_id;
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

When does this case happen? I'm cautious here because I don't think we want any previous name that names a class type to be merged. Eg, if the previous declaration was an ImportRef naming alias C = OtherClass;, then that shouldn't merge with class C even though it was a class type. But if I'm reading ResolvePrevInstForMerge correctly, you'll get a ClassType in both the case of an imported class declaration and in the case of any other imported declaration that constant-evaluates to a class type.

Copy link
Contributor Author

@jonmeow jonmeow Apr 22, 2024

Choose a reason for hiding this comment

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

Theoretically I agree, but I'd say what you're mentioning (with alias) is not supported right now.

Bear in mind an ImportRef only has the constant value to point at the instruction in the current IR. This is all we have to work with, without a major refactoring. Which maybe should occur, and I have already have spots I'm thinking about this, but that's very much out-of-scope.

@jonmeow jonmeow enabled auto-merge April 22, 2024 14:54
@jonmeow jonmeow added this pull request to the merge queue Apr 22, 2024
Merged via the queue into carbon-language:trunk with commit 5694dd1 Apr 22, 2024
7 checks passed
@jonmeow jonmeow deleted the extern-track branch April 22, 2024 15:14
chandlerc pushed a commit to chandlerc/carbon-lang that referenced this pull request May 2, 2024
CJ-Johnson pushed a commit to CJ-Johnson/carbon-lang that referenced this pull request May 23, 2024
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.

2 participants