Suppress new CollectionIncompatibleType Error Prone check by casting
incompatibly-typed argument to query methods in generic collection types.
This will enable us to make this pattern an error in error-prone preventing
future occurrences of this bug.

Background:

Various generic collection types have methods that take Object rather than
the type parameter you would expect, e.g. Collection#contains. Consider a
Collection<String>.  If someone invokes contains() on that collection and
passes in an argument of type Integer, it can never return true because the
Collection cannot contain any Integers.

This CL changes places where these methods are called with an incompatible
type by casting the argument to the declared type of the method, such as
Object or Collection<?>.  **This does not fix the bug.**  It is
semantically-equivalent code that bypasses the Error Prone check so that the
code will continue to compile after we enable the check in the compiler.
Fixing the bug mechanically is not feasible because the fixes are too complex,
but we want to prevent more instances of this bug from entering the codebase.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=106766437
1 file changed
tree: 8bd8825b058ba30751d83bea85660618460db34a
  1. common/
  2. factory/
  3. service/
  4. util/
  5. value/
  6. .gitignore
  7. .travis.yml
  8. build-pom.xml
  9. checkstyle.xml
  10. CONTRIBUTING.md
  11. LICENSE.txt
  12. pom.xml
  13. README.md
README.md

Auto

A collection of source code generators for Java.

Auto‽

Java is full of code that is mechanical, repetitive, typically untested and sometimes the source of subtle bugs. Sounds like a job for robots!

The Auto subprojects are a collection of code generators that automate those types of tasks. They create the code you would have written, but without the bugs.

Save time. Save code. Save sanity.

Subprojects

  • AutoFactory - JSR-330-compatible factories

    Latest version: 0.1-beta2

  • AutoService - Provider-configuration files for ServiceLoader

    Latest version: 1.0-rc2

  • AutoValue - Immutable value-type code generation for Java 1.6+.

    Latest version: 1.1

  • Common - Helper utilities for writing annotation processors.

    Latest version: 0.4

License

Copyright 2013 Google, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.