SI-8346 Rebuild invariant sets in #toSet, avoiding CCE

SI-3953 caused several types of sets' operations to trivially throw `ClassCastException` after using inherited covariant #toSet method, by doing an unchecked cast that is only safe for intrinsically covariant set data structures like `HashSet`, but totally unsafe for others like `TreeSet` or `Enumeration.ValueSet`.

This change moves the cast to the leaves of the class hierarchy where that is safe, and incidentally undeprecates overriding Set#toSet.