Eta-expanding a tree means converting a method reference to a function value.
Eta-expanding a tree means converting a method reference to a function value.
The tree to expand
The type of the method reference
The arity of the expected function type
and assume the lifted application of tree
(@see liftApp) is
{ val xs = es; expr }
If xarity matches the number of parameters in mt
, the eta-expansion is
{ val xs = es; (x1, ..., xn) => expr(x1, ..., xn) }
Note that the function value's parameters are untyped, hence the type will
be supplied by the environment (or if missing be supplied by the target
method as a fallback). On the other hand, if xarity
is different from
the number of parameters in mt
, then we cannot propagate parameter types
from the expected type, and we fallback to using the method's original
parameter types instead.
In either case, the result is an untyped tree, with es
and expr
as typed splices.
Lift out function prefix and all arguments from application
Lift out function prefix and all arguments from application
pre.f(arg1, ..., argN) becomes
val x0 = pre val x1 = arg1 ... val xN = argN x0.f(x1, ..., xN)
But leave idempotent expressions alone.
Lift a function argument, stripping any NamedArg wrapper
Lift arguments that are not-idempotent into ValDefs in buffer defs
and replace by the idents of so created ValDefs.
Lift out common part of lhs tree taking part in an operator assignment such as
Lift out common part of lhs tree taking part in an operator assignment such as
lhs += expr
Lift prefix pre
of an application pre.f(...)
to
Lift prefix pre
of an application pre.f(...)
to
val x0 = pre x0.f(...)
unless pre
is a New
or pre
is idempotent.