Class Infer


  • public final class Infer
    extends Object
    Main entry point for type inference.
    • Constructor Detail

      • Infer

        public Infer​(TypeSystem ts,
                     int jdkVersion,
                     TypeInferenceLogger logger)
        Creates a new instance.
        Parameters:
        ts - Type system
        jdkVersion - JDK version to use. Type inference was changed in Java 8 to propagate the context type.
        logger - Strategy to log failures
    • Method Detail

      • isPreJava8

        public boolean isPreJava8()
      • getTypeSystem

        public TypeSystem getTypeSystem()
      • inferFunctionalExprInUnambiguousContext

        public void inferFunctionalExprInUnambiguousContext​(PolySite<ExprMirror.FunctionalExprMirror> site)
        Infer lambdas and method references that have a target type: cast contexts, and some assignment contexts (not inferred, not return from lambda).
      • inferInvocationRecursively

        public void inferInvocationRecursively​(MethodCallSite site)
        Determines the most specific applicable method for the given call site.

        The returned method type may be TypeSystem.UNRESOLVED_METHOD, in which case no method is applicable (compile-time error).

        The returned method type may contain un-instantiated inference variables, which depend on the target type. In that case those variables and their bounds will have been duplicated into the inference context of the [site].

        The given call site should mention information like the expected return type, to help inference. This should be non-null if we're in an invocation or assignment context, otherwise can be left blank.