Class DefaultTypeArgumentInference

java.lang.Object
org.checkerframework.framework.util.typeinference.DefaultTypeArgumentInference
All Implemented Interfaces:
TypeArgumentInference

public class DefaultTypeArgumentInference extends Object implements TypeArgumentInference
An implementation of TypeArgumentInference that mostly follows the process outlined in JLS7 See the JLS 7: JLS §5.12.2.7

Note, there are some deviations JLS 7 for the following cases:

  • Places where the JLS is vague. For these cases, first the OpenJDK implementation was consulted and then we favored the behavior we desire rather than the implied behavior of the JLS or JDK implementation.
  • The fact that any given type variable type may or may not have annotations for multiple hierarchies means that constraints are more complicated than their Java equivalents. Every constraint must identify the hierarchies to which they apply. This makes solving the constraint sets more complicated.
  • If an argument to a method is null, then the JLS says that it does not constrain the type argument. However, null may constrain the qualifiers on the type argument, so it is included in the constraints but is not used as the underlying type of the type argument.
TODO: The following limitations need to be fixed, as at the time of this writing we do not have the time to handle them:
  • The GlbUtil does not correctly handled wildcards/typevars when the glb result should be a wildcard or typevar
  • Interdependent Method Invocations -- Currently we do not correctly handle the case where two methods need to have their arguments inferred and one is the argument to the other. E.g.
    
     <T> T get()
     <S> void set(S s)
     set(get())
     
    Presumably, we want to detect these situations and combine the set of constraints with T <: S.