Arun Giridhar wrote:I think they should add that feature to Compiler to auto-identify type of value
That would be impossible (or at least far more complicated than it's worth). The compiler is doing static analysis based on the reference type.
The real question is: if you want the compiler to know you can add strings, why don't you tell it? At the moment you're telling it that isn't safe. The only thing the compiler is doing wrong is believing what you told it, which is that that
TreeSet could be a set of
anything.