Community
Participate
Working Groups
@Data class Foo implements Comparable<Foo> { int index override compareTo(Foo that) { val byIndex = Ordering.natural.onResultOf[index] byIndex.compare(this, that) } } generates: @Data @SuppressWarnings("all") public class Foo implements Comparable<Foo> { private final int index; @Override public int compareTo(final Foo that) { int _xblockexpression = (int) 0; { Ordering<Integer> _natural = Ordering.<Integer>natural(); final Function<Foo, Integer> _function = new Function<Foo, Integer>() { @Override public Integer apply(final Foo it) { return Integer.valueOf(Foo.this.index); // This should be it.index! } }; final Ordering<Foo> byIndex = _natural.<Foo>onResultOf(_function); _xblockexpression = byIndex.compare(this, that); } return _xblockexpression; } // ... } If I change the critical line to: val byIndex = Ordering.natural.onResultOf[it.index] the compiler gives an error incorrectly: The method or field index is undefined for the type Foo If I qualify the onResultOf call: val byIndex = Ordering.natural.<Foo>onResultOf[index] then the generated code will look like as expected: return Integer.valueOf(it.index); This is probably related to: https://bugs.eclipse.org/bugs/show_bug.cgi?id=422864