Interface TypeArgumentInference

All Known Implementing Classes:

public interface TypeArgumentInference
Instances of TypeArgumentInference are used to infer the types of method type arguments when no explicit arguments are provided.

e.g. If we have a method declaration:

 <A,B> B method(A a, B b) {...}
And an invocation of that method:

 method("some Str", 35);
TypeArgumentInference will determine what the type arguments to type parameters A and B are. In Java, if T(A) = the type argument for a, in the above example T(A) == String and T(B) == Integer

For the Checker Framework we also need to infer reasonable annotations for these type arguments. For information on inferring type arguments see the documentation in JLS7 and JLS8:

Note: It appears that Java 8 greatly improved the type argument inference and related error messaging but I have found it useful to consult the JLS 7 as well.

  • Method Details

    • inferTypeArgs

      Infer the type arguments for the method or constructor invocation given by invocation.
      typeFactory - the type factory used to create methodType
      invocation - a tree representing the method or constructor invocation for which we are inferring type arguments
      methodElem - the element for the declaration of the method being invoked
      methodType - the declaration type of method elem
      a mapping between the Java type parameter and the annotated type that was inferred for it. Note: We use the Java TypeVariable type because this uniquely identifies a declaration where as two uses of an AnnotatedTypeVariable may be uses of the same declaration but are not .equals to each other.