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
Type members
Classlikes
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:
- Implement constant folding over inlined code
- Selectively expand ifs with constant conditions
- Inline arguments that are by-name closures
- Make sure inlined code is type-correct.
- Make sure that the tree's typing is idempotent (so that future -Ycheck passes succeed)
A utility object offering methods for rewriting inlined code
A utility object offering methods for rewriting inlined code
Value members
Concrete methods
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
.
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.
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.
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.