Skip to content

Add calls-in-place contracts to unsafe operations #367

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

Merged
merged 1 commit into from
Aug 15, 2024
Merged

Add calls-in-place contracts to unsafe operations #367

merged 1 commit into from
Aug 15, 2024

Conversation

JakeWharton
Copy link
Contributor

Closes #361

Comment on lines +721 to +723
if (this.head == null) {
return lambda(null, -1L)
}
Copy link
Contributor Author

@JakeWharton JakeWharton Aug 2, 2024

Choose a reason for hiding this comment

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

This seems like it was a bug. Prior to this, the lambda would be called twice. Once with (null, -1) and then again in the if with (null, 0). Contract validation failed without changing the implementation to early-return here, as I expect was intended.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It was a bug, indeed. Thanks for catching and fixing it!

@fzhinkin fzhinkin self-requested a review August 12, 2024 17:28
@fzhinkin fzhinkin self-requested a review August 15, 2024 13:29
Copy link
Collaborator

@fzhinkin fzhinkin left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the fix, @JakeWharton!

@fzhinkin fzhinkin merged commit ecd60a8 into Kotlin:develop Aug 15, 2024
1 check passed
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