MakeInlineablePassing
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.
Value members
Concrete methods
Inherited methods
Replace tree with a reference to an accessor if needed
Replace tree with a reference to an accessor if needed
- Inherited from:
- Insert
An accessor symbol, create a fresh one unless one exists already
An accessor symbol, create a fresh one unless one exists already
- Inherited from:
- Insert
A definition needs an accessor if it is private, protected, or qualified private and it is not part of the tree that gets inlined. The latter test is implemented by excluding all symbols properly contained in the inline method.
A definition needs an accessor if it is private, protected, or qualified private and it is not part of the tree that gets inlined. The latter test is implemented by excluding all symbols properly contained in the inline method.
Constant vals don't need accessors since they are inlined in FirstTransform. Inline methods don't need accessors since they are inlined in Typer.
- Inherited from:
- MakeInlineableMap
Create an accessor unless one exists already, and replace the original access with a reference to the accessor.
Create an accessor unless one exists already, and replace the original access with a reference to the accessor.
- Value parameters:
- onLHS
The reference is on the left-hand side of an assignment
- reference
The original reference to the non-public symbol
- Inherited from:
- Insert