backport recent changes to Scala 2.10