Class Infer
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.types.internal.infer.Infer
-
public final class Infer extends Object
Main entry point for type inference.
-
-
Field Summary
Fields Modifier and Type Field Description TypeInferenceLogger
LOG
-
Constructor Summary
Constructors Constructor Description Infer(TypeSystem ts, int jdkVersion, TypeInferenceLogger logger)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull ExprMirror.InvocationMirror.MethodCtDecl
getCompileTimeDecl(MethodCallSite site)
TypeInferenceLogger
getLogger()
TypeSystem
getTypeSystem()
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).void
inferInvocationRecursively(MethodCallSite site)
Determines the most specific applicable method for the given call site.boolean
isPreJava8()
MethodCallSite
newCallSite(ExprMirror.InvocationMirror expr, @Nullable JTypeMirror expectedType)
PolySite<ExprMirror.FunctionalExprMirror>
newFunctionalSite(ExprMirror.FunctionalExprMirror mirror, @Nullable JTypeMirror expectedType)
-
-
-
Field Detail
-
LOG
public final TypeInferenceLogger LOG
-
-
Constructor Detail
-
Infer
public Infer(TypeSystem ts, int jdkVersion, TypeInferenceLogger logger)
Creates a new instance.- Parameters:
ts
- Type systemjdkVersion
- 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()
-
getLogger
public TypeInferenceLogger getLogger()
-
newFunctionalSite
public PolySite<ExprMirror.FunctionalExprMirror> newFunctionalSite(ExprMirror.FunctionalExprMirror mirror, @Nullable JTypeMirror expectedType)
-
newCallSite
public MethodCallSite newCallSite(ExprMirror.InvocationMirror expr, @Nullable JTypeMirror expectedType)
-
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.
-
getCompileTimeDecl
public @NonNull ExprMirror.InvocationMirror.MethodCtDecl getCompileTimeDecl(MethodCallSite site)
-
-