wala/WALA — pull request #53 by aaandrewww (2014-05-22 03:46:18+00:00)
Title: Fix bug in ClassHierarchy.getLeastCommonSuperClass and imprecision in type inference

The bug in ClassHierarchy can result in getting a class one step too far up the hierarchy if one of the arguments to getLeastCommonSuperClass is a subclass of the other.

The imprecision in type inference only shows up for array types. When merging a point array type with a cone array type the inference always returned java.lang.Object, even when the two arrays have the same base type. Since it is always OK to return the cone type when the underlying types are equal we can fix this imprecision and save a few cycles if we first check the underlying types for equality.

The type inference is still imprecise for arrays since Java arrays are covariant (yuck!). In WALA's type inference, merging Object[] with String[] will result in java.lang.Object, but it does not violate Java's type system to merge these to String[]. When the two are equal this merging requires no extra work, whereas merging for covariant arrays requires one to find the least common super class. I will fix this second issue in my fork and submit a separate pull request; I'm not sure whether there is some greater reason for WALA's type inference to not be precise in this case.