private static String identifyBadCast ( Type lhs , Type rhs , Types types ) { if ( ! lhs . isPrimitive ( ) ) { return null ; } if ( types . isConvertible ( rhs , lhs ) ) { // Exemption if the rhs is convertible to the lhs. // This allows, e.g.: <byte> &= <byte> since the narrowing conversion can never be // detected. // This also allows, for example, char += char, which could overflow, but this is no // different than any other integral addition. return null ; } return String . format ( "Compound assignments from %s to %s hide lossy casts" , prettyType ( rhs ) , prettyType ( lhs ) ) ; }
Classifies bad casts .