scala/scala — pull request #1841 by adriaanm (2013-01-04 19:50:01+00:00)
Title: Fix Iterator#copyToArray (fixes SI-6827).

As pointed out in #scala, when using a non-zero start it's possible
to get an ArrayIndexOutOfBoundsException due to an incorrect bounds
check. This patch fixes this, as well as another potential bounds
error, and adds test cases.

Incorporates some other suggestions by Som-Snytt to ensure that
callers will get useful error messages in cases where the start
parameter is wrong (negative or out-of-array-bounds).

(rebase of #1785)