Skip to content

Commit

Permalink
[fixes projectlombok#2741] Handle inner method invocations first
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawi01 committed Feb 7, 2021
1 parent ed4ced1 commit d42a6fe
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/lombok/javac/handlers/HandleExtensionMethod.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2014 The Project Lombok Authors.
* Copyright (C) 2012-2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -152,8 +152,9 @@ public void replace() {

@Override
public Void visitMethodInvocation(final MethodInvocationTree tree, final Void p) {
super.visitMethodInvocation(tree, p);
handleMethodCall((JCMethodInvocation) tree);
return super.visitMethodInvocation(tree, p);
return null;
}

private void handleMethodCall(final JCMethodInvocation methodCall) {
Expand Down
15 changes: 15 additions & 0 deletions test/transform/resource/after-delombok/ExtensionMethodChain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.Arrays;
import java.util.List;

class ExtensionMethodChain {
public void test() {
ExtensionMethodChain.Extensions.intValue("1").intValue();
}


static class Extensions {
public static Integer intValue(String s) {
return Integer.valueOf(s);
}
}
}
19 changes: 19 additions & 0 deletions test/transform/resource/after-ecj/ExtensionMethodChain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.Arrays;
import java.util.List;
import lombok.experimental.ExtensionMethod;
@ExtensionMethod(ExtensionMethodChain.Extensions.class) class ExtensionMethodChain {
static class Extensions {
Extensions() {
super();
}
public static Integer intValue(String s) {
return Integer.valueOf(s);
}
}
ExtensionMethodChain() {
super();
}
public void test() {
ExtensionMethodChain.Extensions.intValue("1").intValue();
}
}
17 changes: 17 additions & 0 deletions test/transform/resource/before/ExtensionMethodChain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.util.Arrays;
import java.util.List;
import lombok.experimental.ExtensionMethod;

@ExtensionMethod(ExtensionMethodChain.Extensions.class)
class ExtensionMethodChain {

public void test() {
"1".intValue().intValue();
}

static class Extensions {
public static Integer intValue(String s) {
return Integer.valueOf(s);
}
}
}

0 comments on commit d42a6fe

Please sign in to comment.