@ExtensionMethod broken for javac in nearly all cases #472

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

Projects

None yet

1 participant

@lombokissues
Collaborator

Migrated from Google Code (issue 399)

@lombokissues
Collaborator

๐Ÿ‘ค pe.fips ย  ๐Ÿ•— Jul 13, 2012 at 13:26 UTC

While moving @ ExtensionMethod to lombok a small bug got introduced resulting in "cannot find symbol" errors. I'm going to fix it real quick.

The main point is, that up until now TestWithDelombok is not able to uncover these bugs when running the tests, since we have no attribution phase in delombok.
So I'm suggesting that we add this phase to delombok, see the attached patch.
(also, adding dataflow checks shouldn't hurt)

Example:

import lombok.experimental.ExtensionMethod;
import java.util.Arrays;

@ ExtensionMethod({Arrays.class, ExtensionMethodExample.Extensions.class})
class ExtensionMethodExample {
public String test() {
int[] intArray = {5, 3, 8, 2};
intArray.sort();

String iAmNull = null;
return iAmNull.or("hELlO, WORlD!".toTitleCase());

}

static class Extensions {
public static <T> T or(T obj, T ifNull) {
return obj != null ? obj : ifNull;
}

public static String toTitleCase(String in) {
  if (in.isEmpty()) return in;
  return &quot;&quot; + Character.toTitleCase(in.charAt(0)) + in.substring(1).toLowerCase();
}

}
}

Would give the following error in delombok (before the bugfix):

-1:-1 ERROR cannot find symbol
symbol : variable java.util.Arrays
location: class ExtensionMethodExample

@lombokissues
Collaborator

๐Ÿ‘ค pe.fips ย  ๐Ÿ•— Jul 13, 2012 at 13:26 UTC

๐Ÿ”— delombok.patch View file

@lombokissues
Collaborator

๐Ÿ‘ค pe.fips ย  ๐Ÿ•— Jul 13, 2012 at 13:29 UTC

Fixed with commit 0682634.

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Jul 16, 2012 at 22:21 UTC

Fix is in edge release: https://projectlombok.org/download-edge.html

will be in 0.11.4

@lombokissues lombokissues added this to the 0.11.4 milestone Jul 14, 2015
@lombokissues
Collaborator

End of migration

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