Class 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 Detail

      • AbstractCollectionIncompatibleTypeMatcher

        public AbstractCollectionIncompatibleTypeMatcher()
    • Method Detail

      • extractTypeArgAsMemberOfSupertype

        @Nullable
        protected static 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