deduplicating lambda methods
amaembo at gmail.com
Mon Mar 5 07:51:40 UTC 2018
> E.g. when diffing the lambda bodies for `s -> s` and `x -> x` it sees
`s` and `x` are both the first parameter of their enclosing lambdas.
By the way how types are matched? I assume that you won't merge `s -> s`
and `x -> x`
if `s` is String and `x` is an int, right? However merging two lambdas like
`s -> true` and `sb -> true`
where `s` is a String and `sb` is a StringBuilder seems possible (creating
a synthetic method which
receives an Object). Also two lambdas like `list -> list.size()` can be
merged if the parameter types
differ in type parameters (e.g. List<String> and List<Integer>), but have
the same erasure.
On Mon, Mar 5, 2018 at 10:59 AM, Liam Miller-Cushon <cushon at google.com>
> On Fri, Mar 2, 2018 at 8:01 PM, Vicente Romero <vicente.romero at oracle.com>
> > 1) How to identifying duplicates: I have a prototype that runs during
> >> lambda desugaring and identifies duplicates by diffing ASTs. Is that the
> >> best place for deduplication, or it worth considering comparing
> >> code instead of ASTs?
> > are you doing an exact diff? I assume that we want: s -> s to be equal to
> > z -> z provided that the target is the same
> Lambda parameters are currently handled as a special case. The diff tests
> that the syntax for the two trees is the same, and that the symbols
> associated with identifier and select nodes are equivalent. It accepts
> symbols that correspond to the same parameter in each of the associated
> lambda methods.
> E.g. when diffing the lambda bodies for `s -> s` and `x -> x` it sees that
> `s` and `x` are both the first parameter of their enclosing lambdas.
More information about the amber-dev