APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.comp

public Class Infer

extends Object
Class Inheritance
Imports
com.sun.tools.javac.code.Type.UndetVar.UndetVarListener, .Types.TypeMapping, com.sun.tools.javac.code.*, com.sun.tools.javac.code.Type.*, .Type.UndetVar.InferenceBound, com.sun.tools.javac.code.Symbol.*, com.sun.tools.javac.resources.CompilerProperties.Fragments, .CompilerProperties.Notes, com.sun.tools.javac.tree.JCTree, .JCTree.JCTypeCast, .TreeInfo, com.sun.tools.javac.util.*, .GraphUtils.DottableNode, .JCDiagnostic.DiagnosticPosition, .JCDiagnostic.Fragment, .List, .CompilerInternalException, com.sun.tools.javac.comp.DeferredAttr.AttrMode, .DeferredAttr.DeferredAttrContext, .Infer.GraphSolver.InferenceGraph, .Infer.GraphSolver.InferenceGraph.Node, .Resolve.InapplicableMethodException, .Resolve.VerboseResolutionMode, java.io.IOException, .Writer, java.nio.file.Files, .Path, .Paths, java.util.ArrayList, .Collection, .Collections, .EnumSet, .LinkedHashMap, .LinkedHashSet, .Map, .Optional, .Properties, .Set, java.util.function.BiFunction, .BiPredicate, .Predicate

Helper class for type parameter inference, used by the attribution phase.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract class
Infer.BestLeafSolver

This solver uses an heuristic to pick the best leaf - the heuristic tries to select the node that has maximal probability to contain one or more inference variables in a given list

protected static class
pack-priv class
Infer.CheckBounds

Bound-check incorporation action.

pack-priv class
Infer.CheckInst

Check that the inferred type conforms to all bounds.

pack-priv class
Infer.CheckUpperBounds

Perform pairwise comparison between common generic supertypes of two upper bounds.

pack-priv static enum
Infer.DependencyKind

There are two kinds of dependencies between inference variables.

pack-priv static interface
Infer.FreeTypeListener

Functional interface for defining inference callbacks.

pack-priv static enum
Infer.GraphInferenceSteps

This enumeration defines the sequence of steps to be applied when the graph solver is used.

pack-priv class
Infer.GraphSolver

This is the graph inference solver - the solver organizes all inference variables in a given inference context by bound dependencies - in the general case, such dependencies would lead to a cyclic directed graph (hence the name); the dependency info is used to build an acyclic graph, where all cyclic variables are bundled together.

pack-priv static interface
Infer.GraphStrategy

Graph inference strategy - act as an input to the inference solver; a strategy is composed of two ingredients: (i) find a node to solve in the inference graph, and (ii) tell th engine when we are done fixing inference variables

pack-priv class
public abstract class
Infer.IncorporationAction

This class is the root of all incorporation actions.

pack-priv static record
Infer.IncorporationBinaryOpKey

This class encapsulates a basic incorporation operation; incorporation operations takes two type operands and a kind.

pack-priv static enum
Infer.IncorporationBinaryOpKind

Three kinds of basic operation are supported as part of an incorporation step: (i) subtype check, (ii) same type check and (iii) bound addition (either upper/lower/eq bound).

pack-priv class
Infer.IncorporationEngine

This class models an incorporation engine.

public static class
Infer.InferenceException

This exception class is design to store a list of diagnostics corresponding to inference errors that can arise during a method applicability check.

pack-priv static enum
Infer.InferenceStep

The inference process can be thought of as a sequence of steps.

pack-priv abstract class
Infer.LeafSolver

Simple solver strategy class that locates all leaves inside a graph and picks the first leaf as the next node to solve

public class
Infer.PartiallyInferredMethodType

A partially inferred method/constructor type; such a type can be checked multiple times against different targets.

pack-priv class
Infer.PropagateBounds

Perform propagation of bounds.

pack-priv class
Infer.SubstBounds

Replace undetvars in bounds and check that the inferred type conforms to all bounds.

Field Summary

Modifier and TypeField and Description
public static final Type
anyPoly

A value for prototypes that admit any type, including polymorphic ones.

pack-priv Check
private final String
dependenciesFolder

folder in which the inference dependency graphs should be written.

pack-priv JCDiagnostic.Factory
private final boolean
pack-priv final InferenceContext
private final boolean
pack-priv Types.TypeMapping<Void>
pack-priv Map<Infer.IncorporationBinaryOpKey, Boolean>
incorporationCache

an incorporation cache keeps track of all executed incorporation-related operations

pack-priv Infer.IncorporationEngine
protected static final Context.Key<Infer>
pack-priv Log
pack-priv static final int
MAX_INCORPORATION_STEPS

max number of incorporation rounds.

private List<String>
pendingGraphs

List of graphs awaiting to be dumped to a file.

pack-priv Resolve
pack-priv Symtab
pack-priv Types

Constructor Summary

AccessConstructor and Description
protected
Infer(Context context)

Method Summary

Modifier and TypeMethod and Description
private Type
asSuper(Type t, Type sup)

private boolean
pack-priv void
doIncorporation(InferenceContext inferenceContext, Warner warn)

Check bounds and perform incorporation.

pack-priv boolean
private void
pack-priv Infer.InferenceException
private Type
pack-priv Type
generateReturnConstraints(JCTree tree, Attr.ResultInfo resultInfo, Type.MethodType mt, InferenceContext inferenceContext)

Generate constraints from the generic method's return type.

pack-priv JCDiagnostic.Fragment
private List<Pair<Type, Type>>
public static Infer
instance(Context context)

pack-priv void
instantiateAsUninferredVars(List<Type> vars, InferenceContext inferenceContext)

Infer cyclic inference variables as described in 15.12.2.8.

public Type
instantiateFunctionalInterface(JCDiagnostic.DiagnosticPosition pos, Type funcInterface, List<Type> paramTypes, Check.CheckContext checkContext)

This method is used to infer a suitable target SAM in case the original SAM type contains one or more wildcards.

pack-priv Type
instantiateMethod(Env<AttrContext> env, List<Type> tvars, Type.MethodType mt, Attr.ResultInfo resultInfo, Symbol.MethodSymbol msym, List<Type> argtypes, boolean allowBoxing, boolean useVarargs, Resolve.MethodResolutionContext resolveContext, Warner warn)

Main inference entry point - instantiate a generic method type using given argument types and (possibly) an expected target-type.

public Type
instantiatePatternType(Type expressionType, Symbol.TypeSymbol patternTypeSymbol)

Infer record type for pattern matching.

private List<Type>
pack-priv Type
instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Symbol.MethodSymbol spMethod, Resolve.MethodResolutionContext resolveContext, List<Type> argtypes)

Compute a synthetic method type corresponding to the requested polymorphic method signature.

private boolean
private void
pack-priv void
reportBoundError(Type.UndetVar uv, Type.UndetVar.InferenceBound ib)

Incorporation error: mismatch between two (or more) bounds of same kind.

pack-priv void
reportBoundError(Type.UndetVar uv, Type.UndetVar.InferenceBound ib1, Type.UndetVar.InferenceBound ib2)

Incorporation error: mismatch between two (or more) bounds of different kinds.

pack-priv void
reportInstError(Type.UndetVar uv, Type.UndetVar.InferenceBound ib)

Incorporation error: mismatch between inferred type and given bound.

private List<Type>
private boolean
shouldPropagate(Type restype, Attr.ResultInfo target, InferenceContext inferenceContext)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait