public interface TypeArgumentInference
<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:
http://docs.oracle.com/javase/specs/jls/se8/html/jls-18.html
http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12.2.7
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.| Modifier and Type | Method and Description |
|---|---|
void |
adaptMethodType(AnnotatedTypeFactory typeFactory,
ExpressionTree invocation,
AnnotatedTypeMirror.AnnotatedExecutableType methodType) |
Map<TypeVariable,AnnotatedTypeMirror> |
inferTypeArgs(AnnotatedTypeFactory typeFactory,
ExpressionTree invocation,
ExecutableElement methodElem,
AnnotatedTypeMirror.AnnotatedExecutableType methodType)
Infer the type arguments for the method or constructor invocation given by invocation.
|
Map<TypeVariable,AnnotatedTypeMirror> inferTypeArgs(AnnotatedTypeFactory typeFactory, ExpressionTree invocation, ExecutableElement methodElem, AnnotatedTypeMirror.AnnotatedExecutableType methodType)
typeFactory - The type factory used to create methodType.invocation - A tree representing the method or constructor invocation for which we are inferring
type argumentsmethodElem - The element for the declaration of the method being invokedmethodType - The declaration type of method elemvoid adaptMethodType(AnnotatedTypeFactory typeFactory, ExpressionTree invocation, AnnotatedTypeMirror.AnnotatedExecutableType methodType)