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

Account for new identity comparison hashes in Sorbet internals #1732

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

vinistock
Copy link
Member

Motivation

The build in main is still breaking because of the changes in sorbet/sorbet#7531.

Now that the hashes are compared by identity, we can no longer use the object_id to figure out if a signature is final or not.

Implementation

I added a feature check so that we decide what to do based on the Sorbet version.

We couldn't force the hash to be compared by identity without breaking Sorbet's own internals, so I don't think there are any other approaches we can take.

Tests

Existing tests should continue to pass.

@vinistock vinistock self-assigned this Dec 15, 2023
@vinistock vinistock requested a review from a team as a code owner December 15, 2023 18:38
@vinistock vinistock merged commit 2e4ab6f into main Dec 15, 2023
29 checks passed
@vinistock vinistock deleted the vs/handle_new_identity_comparison_hashes branch December 15, 2023 19:37
Comment on lines +70 to +74
final_methods = if sorbet_supports?(:identity_comparison)
modules_with_final[signature.owner]
else
modules_with_final[signature.owner.object_id]
end
Copy link
Member

Choose a reason for hiding this comment

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

Could we not have done:

final_methods = modules_with_final[signature.owner] || modules_with_final[signature.owner.object_id]

Copy link
Member Author

Choose a reason for hiding this comment

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

We could. I don't mind either style. Do you prefer getting rid of the feature check?

Copy link
Member

Choose a reason for hiding this comment

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

Tbh, yes, I would like to remove the feature check if we can. We've been preserving feature checks only for cases where we would have to do something different without an alternative way of doing it. In this case, I think we have a perfectly good alternative to do look up twice if we have to, and we know we can never get wrong matches.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call!

(For the record, this was fixed in #1734)

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.

None yet

5 participants