The code here is the naïve implementation, which is known to be broken, according to the Scala ticket referred to in the link above, a solution that doesn't have the kinds of issues the naïve implementation has is outlined there as well.