Class AbstractCollectionIncompatibleTypeMatcher

java.lang.Object
com.google.errorprone.bugpatterns.collectionincompatibletype.AbstractCollectionIncompatibleTypeMatcher

public abstract class AbstractCollectionIncompatibleTypeMatcher extends Object
Extracts the necessary information from a MethodInvocationTree to check whether calls to a method are using incompatible types and to emit a helpful error message.
  • Constructor Details

    • AbstractCollectionIncompatibleTypeMatcher

      public AbstractCollectionIncompatibleTypeMatcher()
  • Method Details

    • matches

      public final @Nullable AbstractCollectionIncompatibleTypeMatcher.MatchResult matches(com.sun.source.tree.ExpressionTree tree, VisitorState state)
    • extractTypeArgAsMemberOfSupertype

      protected static @Nullable com.sun.tools.javac.code.Type extractTypeArgAsMemberOfSupertype(com.sun.tools.javac.code.Type type, com.sun.tools.javac.code.Symbol superTypeSym, int typeArgIndex, com.sun.tools.javac.code.Types types)
      Extracts the appropriate type argument from a specific supertype of the given type. This handles the case when a subtype has different type arguments than the expected type. For example, ClassToInstanceMap<T> implements Map<Class<? extends T>, T>.
      Parameters:
      type - the (sub)type from which to extract the type argument
      superTypeSym - the symbol of the supertype on which the type parameter is defined
      typeArgIndex - the index of the type argument to extract from the supertype
      types - the Types utility class from the VisitorState
      Returns:
      the type argument, if defined, or null otherwise
    • message

      protected String message(AbstractCollectionIncompatibleTypeMatcher.MatchResult result, String sourceType, String targetType)