InlineReducer

dotty.tools.dotc.inlines.InlineReducer
class InlineReducer(inliner: Inliner)(using x$2: Context)

A utility class offering methods for rewriting inlined code

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Type members

Types

The result type of reducing a match. It consists optionally of a list of bindings for the pattern-bound variables and the RHS of the selected case. Returns None if no case was selected.

The result type of reducing a match. It consists optionally of a list of bindings for the pattern-bound variables and the RHS of the selected case. Returns None if no case was selected.

Attributes

Same as MatchRedux, but also includes a boolean that is true if the guard can be checked at compile time.

Same as MatchRedux, but also includes a boolean that is true if the guard can be checked at compile time.

Attributes

Value members

Concrete methods

def betaReduce(tree: Tree)(using Context): Tree

Rewrite an application

Rewrite an application

((x1, ..., xn) => b)(e1, ..., en)

to

val/def x1 = e1; ...; val/def xn = en; b

where def is used for call-by-name parameters. However, we shortcut any NoPrefix refs among the ei's directly without creating an intermediate binding.

Attributes

If this is a value binding:

If this is a value binding:

  • reduce its rhs if it is a projection and adjust its type accordingly,
  • record symbol -> rhs in the InlineBindings context propery.

Attributes

def reduceInlineMatch(scrutinee: Tree, scrutType: Type, cases: List[CaseDef], typer: Typer)(using Context): MatchRedux

Reduce an inline match

Reduce an inline match

Attributes

mtch

the match tree

scrutType

its fully defined type, or ImplicitScrutineeTypeRef for a summonFrom

scrutinee

the scrutinee expression, assumed to be pure, or EmptyTree for a summonFrom

typer

The current inline typer

Returns:

optionally, if match can be reduced to a matching case: A pair of bindings for all pattern-bound variables and the RHS of the case.

def reduceProjection(tree: Tree)(using Context): Tree

If tree is equivalent to new C(args).x where class C does not have initialization code and x is a parameter corresponding to one of the arguments args, the corresponding argument, otherwise tree itself. Side effects of original arguments need to be preserved.

If tree is equivalent to new C(args).x where class C does not have initialization code and x is a parameter corresponding to one of the arguments args, the corresponding argument, otherwise tree itself. Side effects of original arguments need to be preserved.

Attributes