Issues/8938

Last week, I decided to pick an arbitrary Scala bug and fix it, so I could gain some real experience with the language, while producing something that I wasn't going to throw away after. I wasn't sure how far I'd get, so I didn't bring this up on the mailing list or bug before working on it (sorry!). However, I now have a fix for this issue, as well as fixes for a gap in the tests that allowed the bug to remain unnoticed. I developed on the 2.11.x branch, because that happened to be where Scala's HEAD reference points to.

The hacker guide includes the following quote:
> Keeping Scala’s git history clean is also important. Therefore we won’t accept pull requests for bug fixes that have more than one commit.
This pull request currently has two commits, which I've kept separate because I think there's a case for doing that. If the reviewer disagrees, I can squash the changes, put the other commit in its own PR, or omit the second change, to bring the PR into compliance.

While preparing to submit the pull request, I looked at the 2.12.x branch. It looks like the bug affects that branch as well, and I'm in the process of porting the fix to it.