There are a number of cases where I think type checking should produce
errors, for instance:
def str = "s"
if (str == 12) {...
In IDEA this is described as "Reports calls to *.equals()* and *==*
operator usages where the target and argument are of incompatible types.
While such a call might theoretically be useful, most likely it represents
a bug."
As that text says, I guess it's not always a coding error. But I'm
interested in how hard it would be to add it.
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport#checkCompatibleAssignmentTypes
seems to have the code for this, and StaticTypeCheckingVisitor seems to do
many checks of this kind, but not this one.
cheers, jamie
|