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

Comments

Projects
None yet
1 participant
@lombokissues
Collaborator

lombokissues commented Jul 14, 2015

Migrated from Google Code (issue 399)

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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

Collaborator

lombokissues commented Jul 14, 2015

👤 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(&quot;hELlO, WORlD!&quot;.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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

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

🔗 delombok.patch View file

Collaborator

lombokissues commented Jul 14, 2015

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

🔗 delombok.patch View file

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

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

Fixed with commit 0682634.

Collaborator

lombokissues commented Jul 14, 2015

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

Fixed with commit 0682634.

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

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

Collaborator

lombokissues commented Jul 14, 2015

👤 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

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

End of migration

Collaborator

lombokissues commented Jul 14, 2015

End of migration

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