Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ExtensionMethod broken for javac in nearly all cases #472

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

@ExtensionMethod broken for javac in nearly all cases #472

lombokissues opened this issue Jul 14, 2015 · 5 comments
Milestone

Comments

@lombokissues
Copy link

Migrated from Google Code (issue 399)

@lombokissues
Copy link
Author

👤 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
Copy link
Author

👤 pe.fips   🕗 Jul 13, 2012 at 13:26 UTC

🔗 delombok.patch View file

@lombokissues
Copy link
Author

👤 pe.fips   🕗 Jul 13, 2012 at 13:29 UTC

Fixed with commit 0682634.

@lombokissues
Copy link
Author

👤 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
Copy link
Author

End of migration

lianhaijun pushed a commit to lianhaijun/lombok that referenced this issue May 8, 2020
fixed projectlombok#472: updated changelog
fixed projectlombok#531: updated changelog
lianhaijun pushed a commit to lianhaijun/lombok that referenced this issue May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant