[java-decompiler] IDEA-346312 adapt patches

- more tests for enums, generics

GitOrigin-RevId: d4c15a9094aec2a789f41d745ecd2d88845a9eb8
This commit is contained in:
Mikhail Pyltsin
2024-09-10 17:20:06 +02:00
committed by intellij-monorepo-bot
parent 8accf5cb9e
commit 26b21b852e
14 changed files with 271 additions and 1 deletions

View File

@@ -326,7 +326,7 @@ public abstract class Exprent implements IMatchable {
}
List<Exprent> lstAllExprents = getAllExprents();
if (lstAllExprents == null || lstAllExprents.isEmpty()) {
if (lstAllExprents.isEmpty()) {
return null;
}

View File

@@ -249,5 +249,7 @@ public class SingleClassesTest extends SingleClassesTestBase {
@Test public void testLambda() { doTest("pkg/TestLambda"); }
@Test public void testCustomSyntheticRecords() { doTest("pkg/TestCustomSyntheticRecords"); }
@Test public void testFinally() { doTest("pkg/TestFinally"); }
@Test public void testEnumInit() { doTest("pkg/TestEnumInit"); }
@Test public void testGenericInit() { doTest("pkg/TestInitGeneric"); }
}

View File

@@ -0,0 +1,74 @@
package pkg;
public class TestEnumInit {
public static void main(String[] args) {
}// 7
static enum TestEnum {
A,
B,
C;
}
static enum TestEnum1 {
A(0),
B(1),
C(2);
private final int anInt;
private TestEnum1(int i) {
this.anInt = i;// 22
}// 23
}
static enum TestEnum2 {
A(0, "0"),
B(1, "1"),
C(2, "2");
private final int anInt;
private TestEnum2(int i, String s) {
this.anInt = i;// 35
}// 36
}
}
class 'pkg/TestEnumInit' {
method 'main ([Ljava/lang/String;)V' {
0 4
}
}
class 'pkg/TestEnumInit$TestEnum1' {
method '<init> (Ljava/lang/String;II)V' {
6 20
7 20
8 20
9 20
a 20
b 21
}
}
class 'pkg/TestEnumInit$TestEnum2' {
method '<init> (Ljava/lang/String;IILjava/lang/String;)V' {
6 32
7 32
8 32
9 32
a 32
b 33
}
}
Lines mapping:
7 <-> 5
22 <-> 21
23 <-> 22
35 <-> 33
36 <-> 34
Not mapped:
21
34

View File

@@ -0,0 +1,111 @@
package pkg;
import java.util.List;
public class TestInitGeneric<T> {
public static void main(String[] args) {
}// 10
public T test() {
return (T)null;// 13
}
class A<T> {
public T test() {
return (T)null;// 18
}
}
class B<L extends T> {
public L test() {
return (L)null;// 24
}
public <AA extends CharSequence> AA test2() {
return (AA)null;// 28
}
}
static class C<L extends CharSequence, K> {
public K test(List<? super L> list) {
return (K)null;// 34
}
public L test2(List<? extends L> list) {
L l = (L)(list.get(0));// 38
System.out.println(l);// 39
return l;// 40
}
}
}
class 'pkg/TestInitGeneric' {
method 'main ([Ljava/lang/String;)V' {
0 6
}
method 'test ()Ljava/lang/Object;' {
0 9
1 9
}
}
class 'pkg/TestInitGeneric$A' {
method 'test ()Ljava/lang/Object;' {
0 14
1 14
}
}
class 'pkg/TestInitGeneric$B' {
method 'test ()Ljava/lang/Object;' {
0 20
1 20
}
method 'test2 ()Ljava/lang/CharSequence;' {
0 24
1 24
}
}
class 'pkg/TestInitGeneric$C' {
method 'test (Ljava/util/List;)Ljava/lang/Object;' {
0 30
1 30
}
method 'test2 (Ljava/util/List;)Ljava/lang/CharSequence;' {
0 34
1 34
2 34
3 34
4 34
5 34
6 34
7 34
8 34
9 34
a 34
b 35
c 35
d 35
e 35
f 35
10 35
11 35
12 36
13 36
}
}
Lines mapping:
10 <-> 7
13 <-> 10
18 <-> 15
24 <-> 21
28 <-> 25
34 <-> 31
38 <-> 35
39 <-> 36
40 <-> 37

View File

@@ -0,0 +1,38 @@
package pkg;
public class TestEnumInit {
public static void main(String[] args) {
}
enum TestEnum {
A, B, C;
}
enum TestEnum1 {
A(0),
B(1),
C(2);
private final int anInt;
TestEnum1(int i) {
anInt = i;
}
}
enum TestEnum2 {
A(0, "0"),
B(1, "1"),
C(2, "2");
private final int anInt;
TestEnum2(int i, String s) {
anInt = i;
}
}
}

View File

@@ -0,0 +1,45 @@
package pkg;
import java.util.List;
public class TestInitGeneric<T> {
public static void main(String[] args) {
}
public T test() {
return null;
}
class A<T> {
public T test() {
return null;
}
}
class B<L extends T> {
public L test() {
return null;
}
public <AA extends CharSequence> AA test2() {
return null;
}
}
static class C<L extends CharSequence, K> {
public K test(List<? super L> list) {
return null;
}
public L test2(List<? extends L> list) {
L l = list.get(0);
System.out.println(l);
return l;
}
}
}