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

IterableOnce#copyToArray uses helper for count [ci: last-only] #10691

Closed
wants to merge 2 commits into from

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Feb 15, 2024

Don't throw (index out of bounds) when there is no runtime work (destination is zero length or count <= 0).

Audited implementations but did not boost the test coverage much.

Fixes scala/bug#12948

@scala-jenkins scala-jenkins added this to the 2.13.14 milestone Feb 15, 2024
@som-snytt som-snytt changed the title IterableOnce#copyToArray uses helper for count IterableOnce#copyToArray uses helper for count [ci: last-only] Feb 15, 2024
@SethTisue SethTisue added the library:collections PRs involving changes to the standard collection library label Feb 15, 2024
@@ -1035,7 +1037,11 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Int = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better update the scala doc for the new behavior.

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 think we'll need a global documentation of out-of-bounds behaviors, as requested in the linked tickets.

This change satisfies the documented behavior, but we need a phrase like "all methods in this package throw on null input", as we read in Javadoc.

@SethTisue SethTisue modified the milestones: 2.13.14, 2.13.15 Mar 13, 2024
@som-snytt som-snytt closed this Mar 20, 2024
@SethTisue SethTisue removed this from the 2.13.15 milestone Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library:collections PRs involving changes to the standard collection library
Projects
None yet
4 participants