@ExtensionMethod in eclipse with 'Class.foo();' or just 'foo()', where the extension is on Object, causes weird stuff to happen. #479

Closed
lombokissues opened this Issue Jul 14, 2015 · 5 comments

Projects

None yet

1 participant

@lombokissues
Collaborator

Migrated from Google Code (issue 406)

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 12, 2012 at 21:37 UTC

Example code:

@ lombok.experimental.ExtensionMethod(Exts.class)
public class Test {
public static void main(String[] args) {
main2();
}

public static void main2() {
    System.out.println(foo());
}

}

class Exts {
public static int foo(Object o) {
System.out.println(o);
return 5;
}
}

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 13, 2012 at 00:49 UTC

Fixed, just in time for 0.11.4. Caught the following weirdnesses in ecj:

super.extMethod();

extMethod();

Object.extMethod();

fixed both for the autocomplete offers and the actual compilation/compile errors, which are different patches.

@lombokissues
Collaborator

๐Ÿ‘ค jose.illescas ย  ๐Ÿ•— Aug 14, 2012 at 09:00 UTC

This fix generate compilation errors, but exist another alternative:

In your example:

 public static void main2() {
 System.out.println(foo());
 }

Can be replaced with: use current class as first argument

 public static void main2() {
 System.out.println(Test.class.foo());
 }
@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 14, 2012 at 10:30 UTC

Not relevant for this fix; that is an entirely different feature.

Please discuss further on the newsgroup.

@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment