Applications

Companion
object
class Object
trait Matchable
class Any
class Typer
class ReTyper
class Typer
class Checker

Type members

Classlikes

class ApplicableToTrees(methRef: TermRef, args: List[Tree], resultType: Type, argMatch: ArgMatch)(using `x$5`: Context) extends TestApplication[Tree[Type]]

Subclass of Application for applicability tests with type arguments and value argument trees.

Subclass of Application for applicability tests with type arguments and value argument trees.

class ApplicableToTypes(methRef: TermRef, args: List[Type], resultType: Type, argMatch: ArgMatch)(using `x$5`: Context) extends TestApplication[Type]

Subclass of Application for applicability tests with value argument types.

Subclass of Application for applicability tests with value argument types.

abstract class Application[Arg](methRef: TermRef, funType: Type, args: List[Arg], resultType: Type)(using `x$5`: Context)
Type Params
Arg

the type of arguments, could be tpd.Tree, untpd.Tree, or Type

Value Params
args

the arguments of the application

funType

the type of the function part of the application

methRef

the reference to the method of the application

resultType

the expected result type of the application

class ApplyToTyped(app: Apply, fun: Tree, methRef: TermRef, args: List[Tree], resultType: Type, applyKind: ApplyKind)(using `x$7`: Context) extends TypedApply[Type]

Subclass of Application for type checking an Apply node with typed arguments.

Subclass of Application for type checking an Apply node with typed arguments.

class ApplyToUntyped(app: Apply, fun: Tree, methRef: TermRef, proto: FunProto, resultType: Type)(using `x$6`: Context) extends TypedApply[Null]

Subclass of Application for type checking an Apply node with untyped arguments.

Subclass of Application for type checking an Apply node with untyped arguments.

enum ArgMatch

The degree to which an argument has to match a formal parameter

The degree to which an argument has to match a formal parameter

abstract class TestApplication[Arg](methRef: TermRef, funType: Type, args: List[Arg], resultType: Type, argMatch: ArgMatch)(using `x$6`: Context) extends Application[Arg]

Subclass of Application for the cases where we are interested only in a "can/cannot apply" answer, without needing to construct trees or issue error messages.

Subclass of Application for the cases where we are interested only in a "can/cannot apply" answer, without needing to construct trees or issue error messages.

abstract class TypedApply[T >: Untyped](app: Apply, fun: Tree, methRef: TermRef, args: List[Tree[T]], resultType: Type, val applyKind: ApplyKind)(using `x$7`: Context) extends Application[Tree[T]]

Subclass of Application for type checking an Apply node, where types of arguments are either known or unknown.

Subclass of Application for type checking an Apply node, where types of arguments are either known or unknown.

Value members

Concrete methods

def ApplyTo(app: Apply, fun: Tree, methRef: TermRef, proto: FunProto, resultType: Type)(using Context): Tree

Typecheck an Apply node with a typed function and possibly-typed arguments coming from proto

Typecheck an Apply node with a typed function and possibly-typed arguments coming from proto

def argCtx(app: Tree)(using Context): Context

If app is a this(...) constructor call, the this-call argument context, otherwise the current context.

If app is a this(...) constructor call, the this-call argument context, otherwise the current context.

def compare(alt1: TermRef, alt2: TermRef)(using Context): Int

Compare to alternatives of an overloaded call or an implicit search.

Compare to alternatives of an overloaded call or an implicit search.

Value Params
alt1,

alt2 Non-overloaded references indicating the two choices

Returns

1 if 1st alternative is preferred over 2nd -1 if 2nd alternative is preferred over 1st 0 if neither alternative is preferred over the other Normal symbols are always preferred over constructor proxies. Otherwise, an alternative A1 is preferred over an alternative A2 if it wins in a tournament that awards one point for each of the following:

  • A1's owner derives from A2's owner.
  • A1's type is more specific than A2's type. If that tournament yields a draw, a tiebreak is applied where an alternative that takes more implicit parameters wins over one that takes fewer.
def compareOwner(sym1: Symbol, sym2: Symbol)(using Context): Int

Compare owner inheritance level.

Compare owner inheritance level.

Value Params
sym1

The first owner

sym2

The second owner

Returns

1 if sym1 properly derives from sym2 -1 if sym2 properly derives from sym1 0 otherwise Module classes also inherit the relationship from their companions. This means, if no direct derivation exists between sym1 and sym2 also perform the following tests:

  • If both sym1 and sym1 are module classes that have companion classes, and sym2 does not inherit implicit members from a base class (#), compare the companion classes.
  • If sym1 is a module class with a companion, and sym2 is a normal class or trait, compare the companion with sym2. Condition (#) is necessary to make compareOwner(_, _) > 0 a transitive relation. For instance: class A extends B object A { given a ... } class B object B extends C { given b ... } class C { given c } Then without (#), and taking A$ for the module class of A, compareOwner(A$, B$) = 1 and compareOwner(B$, C) == 1, but compareOwner(A$, C) == 0. Violating transitivity in this way is bad, since it makes implicit search outcomes compilation order dependent. E.g. if we compare b with c first, we pick b. Then, if we compare a and b, we pick a as solution of the search. But if we start with comparing a with c, we get an ambiguity. With the added condition (#), compareOwner(A$, B$) == 0. This means we get an ambiguity between a and b in all cases.

Rewrite new Array[T](....) if T is an unbounded generic to calls to newGenericArray. It is performed during typer as creation of generic arrays needs a classTag. we rely on implicit search to find one.

Rewrite new Array[T](....) if T is an unbounded generic to calls to newGenericArray. It is performed during typer as creation of generic arrays needs a classTag. we rely on implicit search to find one.

def extMethodApply(methodRef: Tree, receiver: Tree, pt: Type)(using Context): Tree

The typed application

The typed application

() or

where comes from pt if it is a (possibly ignored) PolyProto.

def harmonic[T](harmonize: List[T] => List[T], pt: Type)(op: => List[T])(using Context): List[T]

Apply a transformation harmonize on the results of operation op, unless the expected type pt is fully defined. If the result is different (wrt eq) from the original results of op, revert back to the constraint in force before computing op. This reset is needed because otherwise the original results might have added constraints to type parameters which are no longer implied after harmonization. No essential constraints are lost by this because the result of harmomization will be compared again with the expected type. Test cases where this matters are in pos/harmomize.scala.

Apply a transformation harmonize on the results of operation op, unless the expected type pt is fully defined. If the result is different (wrt eq) from the original results of op, revert back to the constraint in force before computing op. This reset is needed because otherwise the original results might have added constraints to type parameters which are no longer implied after harmonization. No essential constraints are lost by this because the result of harmomization will be compared again with the expected type. Test cases where this matters are in pos/harmomize.scala.

def harmonize(trees: List[Tree])(using Context): List[Tree]

If trees all have numeric value types, and they do not have all the same type, pick a common numeric supertype and try to convert all constant Int literals to this type. If the resulting trees all have the same type, return them instead of the original ones.

If trees all have numeric value types, and they do not have all the same type, pick a common numeric supertype and try to convert all constant Int literals to this type. If the resulting trees all have the same type, return them instead of the original ones.

def hasExtensionMethodNamed(tp: Type, xname: TermName, argType: Type, resultType: Type)(using Context): Boolean

Does tp have an extension method named xname with this-argument argType and result matching resultType?

Does tp have an extension method named xname with this-argument argType and result matching resultType?

def isApplicableExtensionMethod(methodRef: TermRef, receiverType: Type)(using Context): Boolean
def isApplicableMethodRef(methRef: TermRef, args: List[Tree], resultType: Type, keepConstraint: Boolean, argMatch: ArgMatch)(using Context): Boolean

Is given method reference applicable to argument trees args?

Is given method reference applicable to argument trees args?

Value Params
resultType

The expected result type of the application

def isApplicableMethodRef(methRef: TermRef, args: List[Type], resultType: Type, argMatch: ArgMatch)(using Context): Boolean

Is given method reference applicable to argument types args?

Is given method reference applicable to argument types args?

Value Params
resultType

The expected result type of the application

def isApplicableType(tp: Type, args: List[Tree], resultType: Type, keepConstraint: Boolean)(using Context): Boolean

Is given type applicable to argument trees args, possibly after inserting an apply?

Is given type applicable to argument trees args, possibly after inserting an apply?

Value Params
resultType

The expected result type of the application

def isApplicableType(tp: Type, args: List[Type], resultType: Type)(using Context): Boolean

Is given type applicable to argument types args, possibly after inserting an apply?

Is given type applicable to argument types args, possibly after inserting an apply?

Value Params
resultType

The expected result type of the application

def isUnary(tp: Type)(using Context): Boolean

Is tp a unary function type or an overloaded type with with only unary function types as alternatives?

Is tp a unary function type or an overloaded type with with only unary function types as alternatives?

def needsTupledDual(funType: Type, pt: FunProto)(using Context): Boolean

Should we tuple or untuple the argument before application? If auto-tupling is enabled then

Should we tuple or untuple the argument before application? If auto-tupling is enabled then

  • we tuple n-ary arguments where n > 0 if the function consists only of unary alternatives
  • we untuple tuple arguments of infix operations if the function does not consist only of unary alternatives.
def resolveMapped(alts: List[TermRef], f: TermRef => Type, pt: Type)(using Context): List[TermRef]

Resolve overloading by mapping to a different problem where each alternative's type is mapped with f, alternatives with non-existing types are dropped, and the expected type is pt. Map the results back to the original alternatives.

Resolve overloading by mapping to a different problem where each alternative's type is mapped with f, alternatives with non-existing types are dropped, and the expected type is pt. Map the results back to the original alternatives.

Resolve overloaded alternative alts, given expected type pt. Two trials: First, without implicits or SAM conversions enabled. Then, if the first finds no eligible candidates, with implicits and SAM conversions enabled.

Resolve overloaded alternative alts, given expected type pt. Two trials: First, without implicits or SAM conversions enabled. Then, if the first finds no eligible candidates, with implicits and SAM conversions enabled.

def saysNotFound(state: TyperState, memberName: Name)(using Context): Boolean

Does state contain a "NotAMember" or "MissingIdent" message as first pending error message? That message would be $memberName is not a member of ... or Not found: $memberName. If memberName is empty, any name will do.

Does state contain a "NotAMember" or "MissingIdent" message as first pending error message? That message would be $memberName is not a member of ... or Not found: $memberName. If memberName is empty, any name will do.

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

Drop any implicit parameter section

Drop any implicit parameter section

def tryApplyingExtensionMethod(methodRef: TermRef, receiver: Tree)(using Context): Option[Tree]

Assuming methodRef is a reference to an extension method defined e.g. as

Assuming methodRef is a reference to an extension method defined e.g. as

extension [T1, T2](using A)(using B, C)(receiver: R)(using D) def foo[T3](using E)(f: F): G = ???

return the tree representing methodRef partially applied to the receiver and all the implicit parameters preceding it (A, B, C) with the type parameters of the extension (T1, T2) inferred. None is returned if the implicit search fails for any of the leading implicit parameters or if the receiver has a wrong type (note that in general the type of the receiver might depend on the exact types of the found instances of the proceding implicits). No implicit search is tried for implicits following the receiver or for parameters of the def (D, E).

def typedApply(tree: Apply, pt: Type)(using Context): Tree

Typecheck application. Result could be an Apply node, or, if application is an operator assignment, also an Assign or Block node.

Typecheck application. Result could be an Apply node, or, if application is an operator assignment, also an Assign or Block node.

def typedTypeApply(tree: TypeApply, pt: Type)(using Context): Tree
def typedUnApply(tree: Apply, selType: Type)(using Context): Tree
def typedUnApply(tree: UnApply, selType: Type)(using Context): UnApply

A typed unapply hook, can be overridden by re any-typers between frontend and pattern matcher.

A typed unapply hook, can be overridden by re any-typers between frontend and pattern matcher.

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

If tree is a complete application of a compiler-generated apply or copy method of an enum case, widen its type to the underlying type by means of a type ascription, as long as the widened type is still compatible with the expected type. The underlying type is the intersection of all class parents of the orginal type.

If tree is a complete application of a compiler-generated apply or copy method of an enum case, widen its type to the underlying type by means of a type ascription, as long as the widened type is still compatible with the expected type. The underlying type is the intersection of all class parents of the orginal type.

Inherited methods

def constrainResult(meth: Symbol, mt: Type, pt: Type)(using Context): Boolean

Constrain result with special case if meth is an inlineable method in an inlineable context. In that case, we should always succeed and not constrain type parameters in the expected type, because the actual return type can be a subtype of the currently known return type. However, we should constrain parameters of the declared return type. This distinction is achieved by replacing expected type parameters with wildcards.

Constrain result with special case if meth is an inlineable method in an inlineable context. In that case, we should always succeed and not constrain type parameters in the expected type, because the actual return type can be a subtype of the currently known return type. However, we should constrain parameters of the declared return type. This distinction is achieved by replacing expected type parameters with wildcards.

Inherited from
Compatibility
def constrainResult(mt: Type, pt: Type)(using Context): Boolean

Check that the result type of the current method fits the given expected result type.

Check that the result type of the current method fits the given expected result type.

Inherited from
Compatibility
def isCompatible(tp: Type, pt: Type)(using Context): Boolean

A type tp is compatible with a type pt if one of the following holds:

A type tp is compatible with a type pt if one of the following holds:

  1. tp is a subtype of pt
  2. pt is by name parameter type, and tp is compatible with its underlying type
  3. there is an implicit conversion from tp to pt.
  4. tp is a numeric subtype of pt (this case applies even if implicit conversions are disabled) If pt is a by-name type, we compare against the underlying type instead.
Inherited from
Compatibility

Like normalize and then isCompatible, but using a subtype comparison with necessary eithers that does not unnecessarily truncate the constraint space, returning false instead.

Like normalize and then isCompatible, but using a subtype comparison with necessary eithers that does not unnecessarily truncate the constraint space, returning false instead.

Inherited from
Compatibility
def normalizedCompatible(tp: Type, pt: Type, keepConstraint: Boolean)(using Context): Boolean

Test compatibility after normalization. If keepConstraint is false, the current constraint set will not be modified by this call.

Test compatibility after normalization. If keepConstraint is false, the current constraint set will not be modified by this call.

Inherited from
Compatibility
def viewExists(tp: Type, pt: Type)(using Context): Boolean

Is there an implicit conversion from tp to pt?

Is there an implicit conversion from tp to pt?

Inherited from
Compatibility