IDEA-204310: Decompiler adds redundant imports for lambdas

master
md_5 6 years ago committed by Egor Ushakov
parent ca01d9877b
commit 8f2a97adc3
  1. 3
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
  2. 271
      testData/results/TestClassLambda.dec

@ -143,7 +143,8 @@ public class NewExprent extends Exprent {
if (anonymous) {
ClassNode child = DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value);
if (!enumConst) {
// IDEA-204310 - avoid backtracking later on for lambdas (causes spurious imports)
if (!enumConst && (!lambda || DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS))) {
String enclosing = null;
if (!lambda && constructor != null) {

@ -5,10 +5,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.OptionalInt;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.Predicate;
import java.util.function.Supplier;
public class TestClassLambda {
@ -90,43 +87,51 @@ public class TestClassLambda {
class 'pkg/TestClassLambda' {
method 'lambda$testLambda$0 (ILjava/lang/Integer;)V' {
0 20
2 20
5 20
6 20
7 21
c 21
e 21
11 21
12 21
15 22
0 17
2 17
5 17
6 17
7 18
c 18
e 18
11 18
12 18
15 19
}
method 'testLambda ()V' {
7 17
8 17
e 17
f 17
15 17
16 17
1c 17
1d 17
23 17
24 17
2a 17
2c 17
33 17
35 17
39 17
3c 17
3d 18
40 18
41 18
4a 19
4f 23
7 14
8 14
e 14
f 14
15 14
16 14
1c 14
1d 14
23 14
24 14
2a 14
2c 14
33 14
35 14
39 14
3c 14
3d 15
40 15
41 15
4a 16
4f 20
}
method 'lambda$testLambda1$1 (I)V' {
0 25
a 25
13 25
16 25
19 26
}
method 'lambda$testLambda1$2 (I)V' {
0 28
a 28
13 28
@ -134,153 +139,145 @@ class 'pkg/TestClassLambda' {
19 29
}
method 'lambda$testLambda1$2 (I)V' {
0 31
a 31
13 31
16 31
19 32
}
method 'testLambda1 ()V' {
0 26
3 26
4 26
b 29
12 32
13 33
0 23
3 23
4 23
b 26
12 29
13 30
}
method 'lambda$testLambda2$3 (II)I' {
2 37
5 37
2 34
5 34
}
method 'testLambda2 ()V' {
5 36
9 39
5 33
9 36
}
method 'testLambda3 ()V' {
5 42
9 43
5 39
9 40
}
method 'testLambda4 ()V' {
5 46
9 47
5 43
9 44
}
method 'testLambda5 ()V' {
0 50
2 50
e 51
12 52
0 47
2 47
e 48
12 49
}
method 'lambda$testLambda6$4 (IILjava/lang/String;)Z' {
2 59
5 59
9 59
d 59
15 59
2 56
5 56
9 56
d 56
15 56
}
method 'testLambda6 ()V' {
7 55
9 56
e 56
f 56
10 56
12 57
17 57
18 57
19 57
22 58
28 61
7 52
9 53
e 53
f 53
10 53
12 54
17 54
18 54
19 54
22 55
28 58
}
method 'testLambda7 ([Ljava/lang/annotation/Annotation;)V' {
1 64
9 64
f 65
1 61
9 61
f 62
}
method 'reduce (Ljava/util/function/IntBinaryOperator;)Ljava/util/OptionalInt;' {
0 68
1 68
0 65
1 65
}
method 'function (Ljava/util/function/Supplier;)Ljava/lang/String;' {
1 72
6 72
9 72
1 69
6 69
9 69
}
method 'localMax (II)I' {
0 76
1 76
0 73
1 73
}
method 'lambda$null$5 (I)V' {
0 83
a 83
13 83
16 83
19 84
0 80
a 80
13 80
16 80
19 81
}
method 'lambda$nestedLambdas$6 (I)V' {
6 84
7 85
11 85
1a 85
1d 85
20 86
6 81
7 82
11 82
1a 82
1d 82
20 83
}
method 'nestedLambdas ()V' {
0 80
1 80
8 86
9 87
0 77
1 77
8 83
9 84
}
}
Lines mapping:
29 <-> 18
30 <-> 19
32 <-> 20
33 <-> 21
34 <-> 22
35 <-> 23
36 <-> 24
39 <-> 27
40 <-> 30
41 <-> 33
42 <-> 34
45 <-> 37
46 <-> 40
49 <-> 43
50 <-> 44
53 <-> 47
54 <-> 48
57 <-> 51
58 <-> 52
59 <-> 53
62 <-> 56
63 <-> 57
64 <-> 58
65 <-> 59
66 <-> 62
69 <-> 65
70 <-> 66
73 <-> 69
77 <-> 73
81 <-> 77
85 <-> 81
86 <-> 87
87 <-> 85
88 <-> 86
89 <-> 87
90 <-> 88
29 <-> 15
30 <-> 16
32 <-> 17
33 <-> 18
34 <-> 19
35 <-> 20
36 <-> 21
39 <-> 24
40 <-> 27
41 <-> 30
42 <-> 31
45 <-> 34
46 <-> 37
49 <-> 40
50 <-> 41
53 <-> 44
54 <-> 45
57 <-> 48
58 <-> 49
59 <-> 50
62 <-> 53
63 <-> 54
64 <-> 55
65 <-> 56
66 <-> 59
69 <-> 62
70 <-> 63
73 <-> 66
77 <-> 70
81 <-> 74
85 <-> 78
86 <-> 84
87 <-> 82
88 <-> 83
89 <-> 84
90 <-> 85

Loading…
Cancel
Save