You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Jamie Echlin <ja...@gmail.com> on 2015/09/07 17:43:56 UTC

static type checking not finding inconvertible types

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