> Irrelevant, this is NOT what I wrote. There is no way you > can add an Integer in my example. It is a stupid and > useless warning.
I'm looking at it from a compiler writers perspective. All you have is a parameterized type left hand side of a declaration/assignment, and and right hand side expression with a generic type. Peeking at the rhs expression to determine if it is a pure constructor would be an utter hack. Why do that when very simple type inference gives you even more, and is sound?
> Your example is just plain bad code (which you intended it > to be, not a knock on you) for a lot of reasons, and you > can't stop bad code.
It's bad code that *could* be stopped if java didn't allow generic types to be assigned to parameterized types. It should be an error, and I was dumbfounded when I found out that it isn't in java for "source" compatibility. I mean, we have to go through utter type bondage with all the wildcard types flying around in normal code, but some sucker comes flying in with a generic type and, blam, the type system is in shambles.
They may as well have slammed covariant generic types in as well: it's useful at times even though it is incorrect formally. (OK, OK, that was a wee bit offsides.)
Agree to disagree?
Cheers, Carson
Flat View: This topic has 370 replies
on 371 pages
[
«
|
131415161718192021
|
»
]