Inliner

class Inliner(call: Tree, rhsToInline: Tree)(using x$3: Context)

Produces an inlined version of call via its inlined method.

Value parameters:
call

the original call to an inlineable method

rhsToInline

the body of the inlineable method that replaces the call.

Companion:
object
class Object
trait Matchable
class Any

Type members

Classlikes

class InlineTyper(initialErrorCount: Int, @constructorOnly nestingLevel: Int) extends ReTyper

A typer for inlined bodies. Beyond standard typing, an inline typer performs the following functions:

A typer for inlined bodies. Beyond standard typing, an inline typer performs the following functions:

  1. Implement constant folding over inlined code
  2. Selectively expand ifs with constant conditions
  3. Inline arguments that are by-name closures
  4. Make sure inlined code is type-correct.
  5. Make sure that the tree's typing is idempotent (so that future -Ycheck passes succeed)
object reducer

A utility object offering methods for rewriting inlined code

A utility object offering methods for rewriting inlined code

Value members

Concrete methods

def accountForOpaques(binding: ValDef)(using Context): ValDef

If binding contains TermRefs that refer to objects with opaque type aliases, add proxy definitions that expose these aliases and substitute such TermRefs with theproxies. Example from pos/opaque-inline1.scala:

If binding contains TermRefs that refer to objects with opaque type aliases, add proxy definitions that expose these aliases and substitute such TermRefs with theproxies. Example from pos/opaque-inline1.scala:

object refined: opaque type Positive = Int inline def Positive(value: Int): Positive = f(value) def f(x: Positive): Positive = x def run: Unit = { val x = 9; val nine = refined.Positive(x) }

This generates the following proxies:

val $proxy1: refined.type{type Positive = Int} = refined.$asInstanceOf$[refined.type{type Positive = Int}] val refined$_this: ($proxy1 : refined.type{Positive = Int}) = $proxy1

and every reference to refined in the inlined expression is replaced by refined_$this.

def addOpaqueProxies(tp: Type, span: Span, forThisProxy: Boolean)(using Context): Unit

If tp contains TermRefs that refer to objects with opaque type aliases, add proxy definitions to opaqueProxies that expose these aliases.

If tp contains TermRefs that refer to objects with opaque type aliases, add proxy definitions to opaqueProxies that expose these aliases.

def dropUnusedDefs(bindings: List[MemberDef], tree: Tree)(using Context): (List[MemberDef], Tree)

Drop any side-effect-free bindings that are unused in expansion or other reachable bindings. Inline def bindings that are used only once.

Drop any side-effect-free bindings that are unused in expansion or other reachable bindings. Inline def bindings that are used only once.

def inlined(sourcePos: SrcPos): Tree

The Inlined node representing the inlined call

The Inlined node representing the inlined call

def integrate(tree: Tree, originalOwner: Symbol)(using Context): Tree

Make tree part of inlined expansion. This means its owner has to be changed from its originalOwner, and, if it comes from outside the inlined method itself, it has to be marked as an inlined argument.

Make tree part of inlined expansion. This means its owner has to be changed from its originalOwner, and, if it comes from outside the inlined method itself, it has to be marked as an inlined argument.

If value argument contains references to objects that contain opaque types, map them to their opaque proxies.

If value argument contains references to objects that contain opaque types, map them to their opaque proxies.

Map first halfs of opaqueProxies pairs to second halfs, using =:= as equality

Map first halfs of opaqueProxies pairs to second halfs, using =:= as equality

def specializeEq(tree: Tree): Tree

Concrete fields

Map all TermRefs that match left element in opaqueProxies to the corresponding right element.

Map all TermRefs that match left element in opaqueProxies to the corresponding right element.