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

#1976. A handlers' order has been changed. #2114

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/lombok/javac/handlers/HandleDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
import lombok.javac.ResolutionResetNeeded;

@ProviderFor(JavacAnnotationHandler.class)
@HandlerPriority(65536) //2^16; to make sure that we also delegate generated methods.
@HandlerPriority(HandleDelegate.HANDLE_DELEGATE_PRIORITY) //2^16; to make sure that we also delegate generated methods.
@ResolutionResetNeeded
public class HandleDelegate extends JavacAnnotationHandler<Delegate> {

Expand All @@ -102,6 +102,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {

private static final String LEGALITY_OF_DELEGATE = "@Delegate is legal only on instance fields or no-argument instance methods.";
private static final String RECURSION_NOT_ALLOWED = "@Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member \"%s\" is @Delegate in type \"%s\"";
public static final int HANDLE_DELEGATE_PRIORITY = 65536;


@Override public void handle(AnnotationValues<Delegate> annotation, JCAnnotation ast, JavacNode annotationNode) {
Expand Down
3 changes: 2 additions & 1 deletion src/core/lombok/javac/handlers/HandleVal.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package lombok.javac.handlers;

import static lombok.core.handlers.HandlerUtil.handleFlagUsage;
import static lombok.javac.handlers.HandleDelegate.HANDLE_DELEGATE_PRIORITY;
import static lombok.javac.handlers.JavacHandlerUtil.*;
import lombok.ConfigurationKeys;
import lombok.val;
Expand Down Expand Up @@ -49,7 +50,7 @@
import com.sun.tools.javac.util.List;

@ProviderFor(JavacASTVisitor.class)
@HandlerPriority(65536) // 2^16; resolution needs to work, so if the RHS expression is i.e. a call to a generated getter, we have to run after that getter has been generated.
@HandlerPriority(HANDLE_DELEGATE_PRIORITY + 100) // 2^16; resolution needs to work, so if the RHS expression is i.e. a call to a generated getter, we have to run after that getter has been generated.
@ResolutionResetNeeded
public class HandleVal extends JavacASTAdapter {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import java.util.function.Function;

public class ValDelegateMethodReference {
public void config() {
final Column<Entity, java.lang.String> column = createColumn(Entity::getValue);
}

private <V> Column<Entity, V> createColumn(Function<Entity, V> func) {
return new Column<>(func);
}
}

class Column<T, V> {
public Column(Function<T, V> vp) {
}
}

class Entity {
private MyDelegate innerDelegate;

@java.lang.SuppressWarnings("all")
public java.lang.String getValue() {
return this.innerDelegate.getValue();
}

@java.lang.SuppressWarnings("all")
public java.lang.Boolean getABoolean() {
return this.innerDelegate.getABoolean();
}

@java.lang.SuppressWarnings("all")
public void setValue(final java.lang.String value) {
this.innerDelegate.setValue(value);
}

@java.lang.SuppressWarnings("all")
public void setABoolean(final java.lang.Boolean aBoolean) {
this.innerDelegate.setABoolean(aBoolean);
}
}

class MyDelegate {
private String value;
private Boolean aBoolean;

@java.lang.SuppressWarnings("all")
public String getValue() {
return this.value;
}

@java.lang.SuppressWarnings("all")
public Boolean getABoolean() {
return this.aBoolean;
}

@java.lang.SuppressWarnings("all")
public void setValue(final String value) {
this.value = value;
}

@java.lang.SuppressWarnings("all")
public void setABoolean(final Boolean aBoolean) {
this.aBoolean = aBoolean;
}
}
58 changes: 58 additions & 0 deletions test/transform/resource/after-ecj/ValDelegateMethodReference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Delegate;
import lombok.val;
import java.util.function.Function;
public class ValDelegateMethodReference {
public ValDelegateMethodReference() {
super();
}
public void config() {
final @val Column<Entity, java.lang.String> column = createColumn(Entity::getValue);
}
private <V>Column<Entity, V> createColumn(Function<Entity, V> func) {
return new Column<>(func);
}
}
class Column<T, V> {
public Column(Function<T, V> vp) {
super();
}
}
class Entity {
private @Delegate MyDelegate innerDelegate;
Entity() {
super();
}
public @java.lang.SuppressWarnings("all") java.lang.Boolean getABoolean() {
return this.innerDelegate.getABoolean();
}
public @java.lang.SuppressWarnings("all") java.lang.String getValue() {
return this.innerDelegate.getValue();
}
public @java.lang.SuppressWarnings("all") void setABoolean(final java.lang.Boolean aBoolean) {
this.innerDelegate.setABoolean(aBoolean);
}
public @java.lang.SuppressWarnings("all") void setValue(final java.lang.String value) {
this.innerDelegate.setValue(value);
}
}
@Getter @Setter class MyDelegate {
private String value;
private Boolean aBoolean;
MyDelegate() {
super();
}
public @java.lang.SuppressWarnings("all") String getValue() {
return this.value;
}
public @java.lang.SuppressWarnings("all") Boolean getABoolean() {
return this.aBoolean;
}
public @java.lang.SuppressWarnings("all") void setValue(final String value) {
this.value = value;
}
public @java.lang.SuppressWarnings("all") void setABoolean(final Boolean aBoolean) {
this.aBoolean = aBoolean;
}
}
35 changes: 35 additions & 0 deletions test/transform/resource/before/ValDelegateMethodReference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Delegate;
import lombok.val;

import java.util.function.Function;

public class ValDelegateMethodReference {

public void config() {
val column = createColumn(Entity::getValue);
}

private <V> Column<Entity, V> createColumn(Function<Entity, V> func) {
return new Column<>(func);
}

}

class Column<T, V> {
public Column(Function<T, V> vp) {}
}

class Entity {
@Delegate
private MyDelegate innerDelegate;
}

@Getter
@Setter
class MyDelegate {
private String value;
private Boolean aBoolean;
}