Inferencing

object Inferencing
Companion
class
class Object
trait Matchable
class Any

Type members

Value members

Concrete methods

def approximateGADT(tp: Type)(using Context): Type

Try to fully define tp. Return whether constraint has changed. Any changed constraint is kept.

Try to fully define tp. Return whether constraint has changed. Any changed constraint is kept.

def captureWildcards(tp: Type)(using Context): Type

Replace every top-level occurrence of a wildcard type argument by a fresh skolem type. The skolem types are of the form $i.CAP, where $i is a skolem of type scala.internal.TypeBox, and CAP is its type member. See the documentation of TypeBox for a rationale why we do this.

Replace every top-level occurrence of a wildcard type argument by a fresh skolem type. The skolem types are of the form $i.CAP, where $i is a skolem of type scala.internal.TypeBox, and CAP is its type member. See the documentation of TypeBox for a rationale why we do this.

def companionRef(tp: Type)(using Context): Type

Following type aliases and stripping refinements and annotations, if one arrives at a class type reference where the class has a companion module, a reference to that companion module. Otherwise NoType

Following type aliases and stripping refinements and annotations, if one arrives at a class type reference where the class has a companion module, a reference to that companion module. Otherwise NoType

If tp is top-level type variable with a lower bound in the current constraint, instantiate it from below. We also look for TypeVars whereever their instantiation could uncover new type members.

If tp is top-level type variable with a lower bound in the current constraint, instantiate it from below. We also look for TypeVars whereever their instantiation could uncover new type members.

def fullyDefinedType(tp: Type, what: String, span: Span)(using Context): Type

The fully defined type, where all type variables are forced. Throws an error if type contains wildcards.

The fully defined type, where all type variables are forced. Throws an error if type contains wildcards.

def inferTypeParams(tree: Tree, pt: Type)(using Context): Tree

If tree has a type lambda type, infer its type parameters by comparing with expected type pt

If tree has a type lambda type, infer its type parameters by comparing with expected type pt

def instantiateDependent(tp: Type, paramss: List[List[Symbol]])(using Context): Unit

Instantiate any type variables in tp whose bounds contain a reference to one of the parameters in paramss.

Instantiate any type variables in tp whose bounds contain a reference to one of the parameters in paramss.

def instantiateSelected(tp: Type, tvars: List[Type])(using Context): Unit

Instantiate selected type variables tvars in type tp in a special mode:

Instantiate selected type variables tvars in type tp in a special mode:

  1. If a type variable is constrained from below (i.e. constraint bound != given lower bound) it is minimized.
  2. Otherwise, if the type variable is constrained from above, it is maximized.
  3. Otherwise, if the type variable has a lower bound != Nothing, it is minimized.
  4. Otherwise, if the type variable has an upper bound != Any, it is maximized. If none of (1) - (4) applies, the type variable is left uninstantiated. The method is called to instantiate type variables before an implicit search.
def isFullyDefined(tp: Type, force: Value)(using Context): Boolean

Is type fully defined, meaning the type does not contain wildcard types or uninstantiated type variables. As a side effect, this will minimize any uninstantiated type variables, according to the given force degree, but only if the overall result of isFullyDefined is true. Variables that are successfully minimized do not count as uninstantiated.

Is type fully defined, meaning the type does not contain wildcard types or uninstantiated type variables. As a side effect, this will minimize any uninstantiated type variables, according to the given force degree, but only if the overall result of isFullyDefined is true. Variables that are successfully minimized do not count as uninstantiated.

def isSkolemFree(tp: Type)(using Context): Boolean
def maximizeType(tp: Type, span: Span, fromScala2x: Boolean)(using Context): List[Symbol]

Instantiate undetermined type variables so that type tp is maximized.

Instantiate undetermined type variables so that type tp is maximized.

Returns

The list of type symbols that were created to instantiate undetermined type variables that occur non-variantly

For all type parameters occurring in tp: If the bounds of tp in the current constraint are equal wrt =:=, instantiate the type parameter to the lower bound's approximation (approximation because of possible F-bounds).

For all type parameters occurring in tp: If the bounds of tp in the current constraint are equal wrt =:=, instantiate the type parameter to the lower bound's approximation (approximation because of possible F-bounds).

def tvarsInParams(tree: Tree, locked: TypeVars)(using Context): List[TypeVar]

The list of uninstantiated type variables bound by some prefix of type T which occur in at least one formal parameter type of a prefix application. Considered prefixes are:

The list of uninstantiated type variables bound by some prefix of type T which occur in at least one formal parameter type of a prefix application. Considered prefixes are:

  • The function f of an application node f(e1, .., en)
  • The function f of a type application node f[T1, ..., Tn]
  • The prefix p of a selection p.f.
  • The result expression e of a block {s1; .. sn; e}.