-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3410 from Rawi01/extensionmethod-in-lambda
Delay replacement of extension methods in arguments
- Loading branch information
Showing
7 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/transform/resource/after-delombok/ExtensionMethodInLambda.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// version 8: | ||
import java.util.function.Function; | ||
|
||
public class ExtensionMethodInLambda { | ||
public void testSimple() { | ||
String test = "test"; | ||
test = ExtensionMethodInLambda.Extensions.map(test, s -> ExtensionMethodInLambda.Extensions.reverse(s)); | ||
} | ||
|
||
public void testSameName() { | ||
String test = "test"; | ||
test = ExtensionMethodInLambda.Extensions.map(test, s -> s.trim()); | ||
} | ||
|
||
public void testArgumentOfInvalidMethod() { | ||
String test = "test"; | ||
test.invalid(s -> s.reverse()); | ||
} | ||
|
||
|
||
static class Extensions { | ||
public static <T, R> R map(T value, Function<T, R> mapper) { | ||
return mapper.apply(value); | ||
} | ||
|
||
public static String reverse(String string) { | ||
return new StringBuilder(string).reverse().toString(); | ||
} | ||
|
||
public static String trim(Integer integer) { | ||
return "0"; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
test/transform/resource/after-ecj/ExtensionMethodInLambda.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import java.util.function.Function; | ||
import lombok.experimental.ExtensionMethod; | ||
public @ExtensionMethod(value = ExtensionMethodInLambda.Extensions.class) class ExtensionMethodInLambda { | ||
static class Extensions { | ||
Extensions() { | ||
super(); | ||
} | ||
public static <T, R>R map(T value, Function<T, R> mapper) { | ||
return mapper.apply(value); | ||
} | ||
public static String reverse(String string) { | ||
return new StringBuilder(string).reverse().toString(); | ||
} | ||
public static String trim(Integer integer) { | ||
return "0"; | ||
} | ||
} | ||
public ExtensionMethodInLambda() { | ||
super(); | ||
} | ||
public void testSimple() { | ||
String test = "test"; | ||
test = ExtensionMethodInLambda.Extensions.map(test, (<no type> s) -> ExtensionMethodInLambda.Extensions.reverse(s)); | ||
} | ||
public void testSameName() { | ||
String test = "test"; | ||
test = ExtensionMethodInLambda.Extensions.map(test, (<no type> s) -> s.trim()); | ||
} | ||
public void testArgumentOfInvalidMethod() { | ||
String test = "test"; | ||
test.invalid((<no type> s) -> s.reverse()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
test/transform/resource/before/ExtensionMethodInLambda.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// version 8: | ||
import java.util.function.Function; | ||
import lombok.experimental.ExtensionMethod; | ||
|
||
@ExtensionMethod(value = ExtensionMethodInLambda.Extensions.class) | ||
public class ExtensionMethodInLambda { | ||
public void testSimple() { | ||
String test = "test"; | ||
test = test.map(s -> s.reverse()); | ||
} | ||
|
||
public void testSameName() { | ||
String test = "test"; | ||
test = test.map(s -> s.trim()); | ||
} | ||
|
||
public void testArgumentOfInvalidMethod() { | ||
String test = "test"; | ||
test.invalid(s -> s.reverse()); | ||
} | ||
|
||
static class Extensions { | ||
public static <T, R> R map(T value, Function<T, R> mapper) { | ||
return mapper.apply(value); | ||
} | ||
|
||
public static String reverse(String string) { | ||
return new StringBuilder(string).reverse().toString(); | ||
} | ||
|
||
public static String trim(Integer integer) { | ||
return "0"; | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test/transform/resource/messages-delombok/ExtensionMethodInLambda.java.messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
19 cannot find symbol symbol: method invalid((s)->s.reverse()) location: variable test of type java.lang.String |
1 change: 1 addition & 0 deletions
1
test/transform/resource/messages-ecj/ExtensionMethodInLambda.java.messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
19 The method invalid((<no type> s) -> {}) is undefined for the type String |
1 change: 1 addition & 0 deletions
1
test/transform/resource/messages-idempotent/ExtensionMethodInLambda.java.messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
17 cannot find symbol symbol: method invalid((s)->s.reverse()) location: variable test of type java.lang.String |