Currently, this document contains some basic terms that are common for different specific inference types. Lately, it might be extended to include some basic description of how inference works.
To avoid confusion with type parameter types, we mostly use Tv
for referencing type variable based on a type parameter named T
Xi <: SomeType
or SomeType <: Xi
or Xi = SomeType
org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
See TypeVariableDependencyInformationProvider
for details.
Two variables Xv
and Yv
are shallowly related if there is some chain of a constraints Xv ~ a_1 ~ .. ~ a_n ~ Yv
where (~
is either <:
or >:
)
Two variables Xv
and Yv
are deeply related if there is some chain of a constraints a_1 ~ .. ~ a_n
where (~
is either <:
or >:
) and a_1
contains Xv
while a_n
contains Yv
.
A tree of calls, in which constraint systems are joined and solved(completed) together
A constraint that doesn't reference any type variables
Completion is a process that for a given call, its CS and postponed atoms (lambdas and callable references) tries to infer some TV and analyze some lambdas
Completion mode
Completion mode (ConstraintSystemCompletionMode
) defines how actively/forcefully the given call is being completed
PARTIAL
— used for calls that are other calls argumentsval x: Int = 1 fun main() { x.plus(run { x }) }
FULL
— used for top statement-level calls and receiversUNTIL_FIRST_LAMBDA
— used for OverloadByLambdaReturnTypePCLA_POSTPONED_CALL
— see pcla.md.A set of callbacks related to inference that being called during function body transformations. See FirInferenceSession
.