Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/org/jetbrains/java/decompiler/main/ClassWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,13 @@ public boolean writeMethod(ClassNode node, StructMethod mt, int methodIndex, Tex

ClassNode currentNode = node;
while (currentNode != null) {
if (currentNode.enclosingMethod != null) {
StructMethod enclosingMethod = currentNode.parent.classStruct.getMethod(currentNode.enclosingMethod);
if (enclosingMethod != null && enclosingMethod.getSignature() != null) {
checker = checker.copy(enclosingMethod.getSignature().typeParameters, enclosingMethod.getSignature().typeParameterBounds);
}
}

GenericClassDescriptor parentSignature = currentNode.classStruct.getSignature();
if (parentSignature != null) {
checker = checker.copy(parentSignature.getChecker());
Expand Down
2 changes: 2 additions & 0 deletions test/org/jetbrains/java/decompiler/SingleClassesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,8 @@ private void registerDefault() {
register(JAVA_17, "TestSwitchOnEnumFake");
register(JAVA_16, "TestSwitchExpressionReturnType");
register(JAVA_8, "TestGenericMapping");
register(JAVA_8, "TestNestedGenerics1");
register(JAVA_11, "TestNestedGenerics2");

registerRaw(CUSTOM, "TestCorruptedSignatures").setExpectedFileName("Signatures.java");
}
Expand Down
40 changes: 40 additions & 0 deletions testData/results/pkg/TestNestedGenerics1.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package pkg;

import java.util.function.Function;

public class TestNestedGenerics1 {
public static <T, R> R test(T t) {
Function<T, R> instance = new Function<T, R>() {// 7
public R apply(T t) {
return null;// 10
}
};
return (R)instance.apply(t);// 13
}
}

class 'pkg/TestNestedGenerics1' {
method 'test (Ljava/lang/Object;)Ljava/lang/Object;' {
7 6
8 11
9 11
a 11
b 11
c 11
d 11
e 11
f 11
}
}

class 'pkg/TestNestedGenerics1$1' {
method 'apply (Ljava/lang/Object;)Ljava/lang/Object;' {
0 8
1 8
}
}

Lines mapping:
7 <-> 7
10 <-> 9
13 <-> 12
36 changes: 36 additions & 0 deletions testData/results/pkg/TestNestedGenerics2.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package pkg;

public class TestNestedGenerics2 {
public static <T, R> R test(T t) {
var instance = new Object() {// 5
R run(T t) {
return null;// 7
}
};
return (R)instance.run(t);// 10
}
}

class 'pkg/TestNestedGenerics2' {
method 'test (Ljava/lang/Object;)Ljava/lang/Object;' {
7 4
8 9
9 9
a 9
b 9
c 9
d 9
}
}

class 'pkg/TestNestedGenerics2$1' {
method 'run (Ljava/lang/Object;)Ljava/lang/Object;' {
0 6
1 6
}
}

Lines mapping:
5 <-> 5
7 <-> 7
10 <-> 10
12 changes: 12 additions & 0 deletions testData/src/java11/pkg/TestNestedGenerics2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pkg;

public class TestNestedGenerics2 {
public static <T, R> R test(T t) {
var instance = new Object() {
R run(T t) {
return null;
}
};
return instance.run(t);
}
}
15 changes: 15 additions & 0 deletions testData/src/java8/pkg/TestNestedGenerics1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pkg;

import java.util.function.Function;

public class TestNestedGenerics1 {
public static <T, R> R test(T t) {
Function<T, R> instance = new Function<T, R>() {
@Override
public R apply(T t) {
return null;
}
};
return instance.apply(t);
}
}