InlineAccessors

class Object
trait Matchable
class Any

Type members

Classlikes

class MakeInlineableDirect(inlineSym: Symbol) extends MakeInlineableMap

Direct approach: place the accessor with the accessed symbol. This has the advantage that we can re-use the receiver as is. But it is only possible if the receiver is essentially this or an outer this, which is indicated by the test that we can find a host for the accessor.

Direct approach: place the accessor with the accessed symbol. This has the advantage that we can re-use the receiver as is. But it is only possible if the receiver is essentially this or an outer this, which is indicated by the test that we can find a host for the accessor.

abstract class MakeInlineableMap(val inlineSym: Symbol) extends TreeMap with Insert

A tree map which inserts accessors for non-public term members accessed from inlined code.

A tree map which inserts accessors for non-public term members accessed from inlined code.

Fallback approach if the direct approach does not work: Place the accessor method in the same class as the inline method, and let it take the receiver as parameter. This is tricky, since we have to find a suitable type for the parameter, which might require additional type parameters for the inline accessor. An example is in the TestPassing class in test run/inline/inlines_1:

Fallback approach if the direct approach does not work: Place the accessor method in the same class as the inline method, and let it take the receiver as parameter. This is tricky, since we have to find a suitable type for the parameter, which might require additional type parameters for the inline accessor. An example is in the TestPassing class in test run/inline/inlines_1:

class C[T](x: T) { private[inlines] def next[U](y: U): (T, U) = (x, y) } class TestPassing { inline def foo[A](x: A): (A, Int) = { val c = new CA c.next(1) } inline def bar[A](x: A): (A, String) = { val c = new CA c.next("") }

C could be compiled separately, so we cannot place the inline accessor in it. Instead, the inline accessor goes into TestPassing and takes the actual receiver type as argument:

def inline$next$i1[A, U](x$0: C[A])(y: U): (A, U) = x$0.nextU

Since different calls might have different receiver types, we need to generate one such accessor per call, so they need to have unique names.

Inherited classlikes

trait Insert
Inherited from
AccessProxies

Value members

Concrete methods

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

Adds accessors for all non-public term members accessed from tree. Non-public type members are currently left as they are. This means that references to a private type will lead to typing failures on the code when it is inlined. Less than ideal, but hard to do better (see below).

Adds accessors for all non-public term members accessed from tree. Non-public type members are currently left as they are. This means that references to a private type will lead to typing failures on the code when it is inlined. Less than ideal, but hard to do better (see below).

Returns

If there are accessors generated, a thicket consisting of the rewritten tree and all accessors, otherwise the original tree.

override def passReceiverAsArg(name: Name)(using Context): Boolean

If an inline accessor name wraps a unique inline name, this is taken as indication that the inline accessor takes its receiver as first parameter. Such accessors are created by MakeInlineablePassing.

If an inline accessor name wraps a unique inline name, this is taken as indication that the inline accessor takes its receiver as first parameter. Such accessors are created by MakeInlineablePassing.

Definition Classes

Inherited methods

def addAccessorDefs(cls: Symbol, body: List[Tree])(using Context): List[Tree]

Add all needed accessors to the body of class cls

Add all needed accessors to the body of class cls

Inherited from
AccessProxies