Backport #2605 to 2.10.x: SI-7149 Use a WeakHashSet for type uniqueness

The issue of uniques accumulating types during the whole compilation run turned out to be especially bad for ScalaTest tests. Scala 2.10.2 requires at least 6GB to compile Scalatest tests. With this patch, 800MB is enough.

Such a dramatic difference in memory consumption and low-risk of this patch makes it appealing to backport it to 2.10.x.

Review by @JamesIry.