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

public Class InferenceContext

extends Object
Class Inheritance
Imports
java.util.Collections, .EnumSet, .LinkedHashMap, .LinkedHashSet, .Map, .Set, java.util.function.Predicate, com.sun.tools.javac.code.Type, .Type.ArrayType, .Type.ClassType, .Type.TypeVar, .Type.UndetVar, .Type.UndetVar.InferenceBound, .Type.WildcardType, .TypeTag, .Types, com.sun.tools.javac.comp.Infer.FreeTypeListener, .Infer.GraphSolver, .Infer.GraphStrategy, .Infer.InferenceException, .Infer.InferenceStep, com.sun.tools.javac.tree.JCTree, com.sun.tools.javac.util.Assert, .List, .ListBuffer, .Warner

An inference context keeps track of the set of variables that are free in the current context. It provides utility methods for opening/closing types to their corresponding free/closed forms. It also provide hooks for attaching deferred post-inference action (see PendingCheck). Finally, it can be used as an entry point for performing upper/lower bound inference (see InferenceKind).

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 class

Field Summary

Modifier and TypeField and Description
pack-priv Types.TypeMapping<Void>
pack-priv Map<JCTree, Type>
pack-priv Map<Infer.FreeTypeListener, List<Type>>
pack-priv Infer
pack-priv List<Type>
inferencevars

list of inference vars in this context

pack-priv InferenceContext
pack-priv Types
pack-priv List<Type>
undetvars

list of inference vars as undet vars

Constructor Summary

AccessConstructor and Description
public
InferenceContext(Infer infer, List<Type> inferencevars)

public
InferenceContext(Infer infer, List<Type> inferencevars, List<Type> undetvars)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addFreeTypeListener(List<Type> types, Infer.FreeTypeListener ftl)

Add custom hook for performing post-inference action

pack-priv void
addVar(Type.TypeVar t)

add a new inference var to this inference context

pack-priv Type
asInstType(Type t)

Replace all free variables in a given type with corresponding instantiated types - if one or more free variable has not been fully instantiated, it will still be available in the resulting type.

pack-priv List<Type>
public final Type
asTypeVar(Type t)

Replace all undet vars in a given type with corresponding free variables

public final Type
asUndetVar(Type t)

Replace all free variables in a given type with corresponding undet vars (used ahead of subtyping/compatibility checks to allow propagation of inference constraints).

pack-priv final List<Type>
pack-priv final List<Type>
boundedVars()

Get list of bounded inference variables (where bound is other than declared bounds).

pack-priv Type
cachedCapture(JCTree tree, Type t, boolean readOnly)

pack-priv void
dupTo(final InferenceContext that)

Copy variable in this inference context to the given context

pack-priv void
dupTo(final InferenceContext that, boolean clone)

private List<Type>
pack-priv final boolean
free(Type t)

is this type free?

pack-priv final boolean
free(List<Type> ts)

pack-priv final List<Type>
freeVarsIn(Type t)

Returns a list of free variables in a given type

pack-priv final List<Type>
pack-priv List<Type>
inferenceVars()

returns the list of free variables (as type-variables) in this inference context

pack-priv List<Type>
pack-priv List<Type>
instvars()

returns the list of instantiated variables (as type-variables) in this inference context

pack-priv InferenceContext
min(List<Type> roots, boolean shouldSolve, Warner warn)

pack-priv void
notifyChange()

Mark the inference context as complete and trigger evaluation of all deferred checks.

pack-priv void
notifyChange(List<Type> inferredVars)

pack-priv List<Type>
restvars()

returns the list of uninstantiated variables (as type-variables) in this inference context

public void
rollback(List<Type> saved_undet)

Restore the state of this inference context to the previous known checkpoint.

public List<Type>
save()

Save the state of this inference context

private void
solve(Infer.GraphStrategy ss, Warner warn)

Solve with given graph strategy.

public void
solve(Warner warn)

Solve all variables in this context.

public void
solve(final List<Type> vars, Warner warn)

Solve all variables in the given list.

public void
solveAny(List<Type> varsToSolve, Warner warn)

Solve at least one variable in given list.

pack-priv List<Type>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public List<Type>
undetVars()

returns the list of undetermined variables in this inference context

pack-priv Type
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

asTypeVarFunback to summary
pack-priv Types.TypeMapping<Void> asTypeVarFun
captureTypeCacheback to summary
pack-priv Map<JCTree, Type> captureTypeCache
freeTypeListenersback to summary
pack-priv Map<Infer.FreeTypeListener, List<Type>> freeTypeListeners
inferback to summary
pack-priv Infer infer
inferencevarsback to summary
pack-priv List<Type> inferencevars

list of inference vars in this context

parentICback to summary
pack-priv InferenceContext parentIC
typesback to summary
pack-priv Types types
undetvarsback to summary
pack-priv List<Type> undetvars

list of inference vars as undet vars

Constructor Detail

InferenceContextback to summary
public InferenceContext(Infer infer, List<Type> inferencevars)
InferenceContextback to summary
public InferenceContext(Infer infer, List<Type> inferencevars, List<Type> undetvars)

Method Detail

addFreeTypeListenerback to summary
pack-priv void addFreeTypeListener(List<Type> types, Infer.FreeTypeListener ftl)

Add custom hook for performing post-inference action

addVarback to summary
pack-priv void addVar(Type.TypeVar t)

add a new inference var to this inference context

asInstTypeback to summary
pack-priv Type asInstType(Type t)

Replace all free variables in a given type with corresponding instantiated types - if one or more free variable has not been fully instantiated, it will still be available in the resulting type.

asInstTypesback to summary
pack-priv List<Type> asInstTypes(List<Type> ts)
asTypeVarback to summary
public final Type asTypeVar(Type t)

Replace all undet vars in a given type with corresponding free variables

asUndetVarback to summary
public final Type asUndetVar(Type t)

Replace all free variables in a given type with corresponding undet vars (used ahead of subtyping/compatibility checks to allow propagation of inference constraints).

asUndetVarsback to summary
pack-priv final List<Type> asUndetVars(List<Type> ts)
boundedVarsback to summary
pack-priv final List<Type> boundedVars()

Get list of bounded inference variables (where bound is other than declared bounds).

cachedCaptureback to summary
pack-priv Type cachedCapture(JCTree tree, Type t, boolean readOnly)
dupToback to summary
pack-priv void dupTo(final InferenceContext that)

Copy variable in this inference context to the given context

dupToback to summary
pack-priv void dupTo(final InferenceContext that, boolean clone)
filterVarsback to summary
private List<Type> filterVars(Predicate<Type.UndetVar> fu)
freeback to summary
pack-priv final boolean free(Type t)

is this type free?

freeback to summary
pack-priv final boolean free(List<Type> ts)
freeVarsInback to summary
pack-priv final List<Type> freeVarsIn(Type t)

Returns a list of free variables in a given type

freeVarsInback to summary
pack-priv final List<Type> freeVarsIn(List<Type> ts)
inferenceVarsback to summary
pack-priv List<Type> inferenceVars()

returns the list of free variables (as type-variables) in this inference context

instTypesback to summary
pack-priv List<Type> instTypes()
instvarsback to summary
pack-priv List<Type> instvars()

returns the list of instantiated variables (as type-variables) in this inference context

minback to summary
pack-priv InferenceContext min(List<Type> roots, boolean shouldSolve, Warner warn)
notifyChangeback to summary
pack-priv void notifyChange()

Mark the inference context as complete and trigger evaluation of all deferred checks.

notifyChangeback to summary
pack-priv void notifyChange(List<Type> inferredVars)
restvarsback to summary
pack-priv List<Type> restvars()

returns the list of uninstantiated variables (as type-variables) in this inference context

rollbackback to summary
public void rollback(List<Type> saved_undet)

Restore the state of this inference context to the previous known checkpoint. Consider that the number of saved undetermined variables can be different to the current amount. This is because new captured variables could have been added.

saveback to summary
public List<Type> save()

Save the state of this inference context

solveback to summary
private void solve(Infer.GraphStrategy ss, Warner warn)

Solve with given graph strategy.

solveback to summary
public void solve(Warner warn)

Solve all variables in this context.

solveback to summary
public void solve(final List<Type> vars, Warner warn)

Solve all variables in the given list.

solveAnyback to summary
public void solveAny(List<Type> varsToSolve, Warner warn)

Solve at least one variable in given list.

solveBasicback to summary
pack-priv List<Type> solveBasic(List<Type> varsToSolve, EnumSet<Infer.InferenceStep> steps)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
undetVarsback to summary
public List<Type> undetVars()

returns the list of undetermined variables in this inference context

updateback to summary
pack-priv Type update(Type t)
com.sun.tools.javac.comp back to summary

pack-priv Class InferenceContext.ReachabilityVisitor

extends Types.UnaryVisitor<Void>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Set<Type>
pack-priv Set<Type>
pack-priv Map<Type, Set<Type>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
pack-priv void
scan(List<Type> roots)

public Void
public Void
public Void
public Void
public Void
public Void
Inherited from com.sun.tools.javac.code.Types.UnaryVisitor:
visit

Field Detail

equivback to summary
pack-priv Set<Type> equiv
minback to summary
pack-priv Set<Type> min
minMapback to summary
pack-priv Map<Type, Set<Type>> minMap

Constructor Detail

ReachabilityVisitorback to summary
pack-priv ReachabilityVisitor()

Method Detail

isEquivback to summary
pack-priv boolean isEquiv(Type.UndetVar from, Type t, Type.UndetVar.InferenceBound boundKind)
scanback to summary
pack-priv void scan(List<Type> roots)
visitArrayTypeback to summary
public Void visitArrayType(Type.ArrayType t, Void _unused)

Overrides com.sun.tools.javac.code.Types.DefaultTypeVisitor.visitArrayType.

Implements com.sun.tools.javac.code.Type.Visitor.visitArrayType.

Annotations
@Override
visitClassTypeback to summary
public Void visitClassType(Type.ClassType t, Void _unused)

Overrides com.sun.tools.javac.code.Types.DefaultTypeVisitor.visitClassType.

Implements com.sun.tools.javac.code.Type.Visitor.visitClassType.

Annotations
@Override
visitTypeback to summary
public Void visitType(Type t, Void _unused)

Implements com.sun.tools.javac.code.Type.Visitor.visitType.

Annotations
@Override
visitTypeVarback to summary
public Void visitTypeVar(Type.TypeVar t, Void aVoid)

Overrides com.sun.tools.javac.code.Types.DefaultTypeVisitor.visitTypeVar.

Implements com.sun.tools.javac.code.Type.Visitor.visitTypeVar.

Annotations
@Override
visitUndetVarback to summary
public Void visitUndetVar(Type.UndetVar t, Void _unused)

Overrides com.sun.tools.javac.code.Types.SimpleVisitor.visitUndetVar.

Implements com.sun.tools.javac.code.Type.Visitor.visitUndetVar.

Annotations
@Override
visitWildcardTypeback to summary
public Void visitWildcardType(Type.WildcardType t, Void _unused)

Overrides com.sun.tools.javac.code.Types.DefaultTypeVisitor.visitWildcardType.

Implements com.sun.tools.javac.code.Type.Visitor.visitWildcardType.

Annotations
@Override