-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix lambda to anonymous class regression (#336)
* fix lambda to anonymous class option * add regression tests for feature * get method references to decompile correctly again
- Loading branch information
1 parent
a3de77e
commit 9dc14fc
Showing
6 changed files
with
151 additions
and
9 deletions.
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
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
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,24 @@ | ||
package pkg; | ||
|
||
public class TestLambdaToAnonymousClass { | ||
Runnable f = new Runnable() { | ||
public run() { | ||
System.out.println();// 4 | ||
} | ||
}; | ||
} | ||
|
||
class 'pkg/TestLambdaToAnonymousClass' { | ||
method 'lambda$new$0 ()V' { | ||
0 5 | ||
1 5 | ||
2 5 | ||
3 5 | ||
4 5 | ||
5 5 | ||
6 6 | ||
} | ||
} | ||
|
||
Lines mapping: | ||
4 <-> 6 |
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,83 @@ | ||
package pkg; | ||
|
||
import java.util.List; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Function; | ||
import java.util.function.IntFunction; | ||
|
||
public class TestLambdaToAnonymousClass2 { | ||
public void test() { | ||
BiConsumer<List<String>, Integer> $ = new BiConsumer() {// 8 | ||
public accept(List l, Integer i) { | ||
Character[] a = (Character[])l.stream().map(new Function() {// 9 | ||
public apply(String st) { | ||
return st.charAt(i);// 10 | ||
} | ||
}).toArray(new IntFunction() { | ||
public apply(int x$0) { | ||
return new Character[x$0];// 11 | ||
} | ||
}); | ||
}// 12 | ||
}; | ||
}// 13 | ||
} | ||
|
||
class 'pkg/TestLambdaToAnonymousClass2' { | ||
method 'test ()V' { | ||
5 9 | ||
6 22 | ||
} | ||
|
||
method 'lambda$test$2 (Ljava/util/List;Ljava/lang/Integer;)V' { | ||
0 11 | ||
1 11 | ||
2 11 | ||
3 11 | ||
4 11 | ||
5 11 | ||
c 11 | ||
d 11 | ||
e 11 | ||
f 11 | ||
10 11 | ||
16 15 | ||
17 15 | ||
18 15 | ||
19 15 | ||
1a 15 | ||
1b 11 | ||
1c 11 | ||
1d 11 | ||
1e 11 | ||
1f 20 | ||
} | ||
|
||
method 'lambda$null$0 (Ljava/lang/Integer;Ljava/lang/String;)Ljava/lang/Character;' { | ||
0 13 | ||
1 13 | ||
2 13 | ||
3 13 | ||
4 13 | ||
5 13 | ||
6 13 | ||
7 13 | ||
8 13 | ||
9 13 | ||
a 13 | ||
b 13 | ||
} | ||
|
||
method 'lambda$null$1 (I)[Ljava/lang/Character;' { | ||
0 17 | ||
4 17 | ||
} | ||
} | ||
|
||
Lines mapping: | ||
8 <-> 10 | ||
9 <-> 12 | ||
10 <-> 14 | ||
11 <-> 18 | ||
12 <-> 21 | ||
13 <-> 23 |
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,5 @@ | ||
package pkg; | ||
|
||
public class TestLambdaToAnonymousClass { | ||
Runnable f = () -> System.out.println(); | ||
} |
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,14 @@ | ||
package pkg; | ||
|
||
import java.util.List; | ||
import java.util.function.*; | ||
|
||
public class TestLambdaToAnonymousClass2 { | ||
public void test() { | ||
BiConsumer<List<String>, Integer> $ = (l, i) -> { | ||
Character[] a = l.stream() | ||
.map(st -> st.charAt(i)) | ||
.toArray(Character[]::new); | ||
}; | ||
} | ||
} |