Skip to content

Commit

Permalink
Fix local record classes that have the parent class as the first
Browse files Browse the repository at this point in the history
parameter
  • Loading branch information
coehlrich committed Aug 17, 2024
1 parent e62bc97 commit 9abb342
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ private static void computeLocalVarsAndDefinitions(ClassNode node) {
if (nd.type != ClassNode.Type.LAMBDA &&
!nd.classStruct.isSynthetic() &&
(nd.access & CodeConstants.ACC_STATIC) == 0 &&
(nd.access & CodeConstants.ACC_INTERFACE) == 0) {
(nd.access & CodeConstants.ACC_INTERFACE) == 0 &&
nd.classStruct.getRecordComponents() == null) {
clTypes.add(nd.type);

Map<String, List<VarFieldPair>> mask = getMaskLocalVars(nd.getWrapper());
Expand Down
1 change: 1 addition & 0 deletions test/org/jetbrains/java/decompiler/SingleClassesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ private void registerDefault() {
register(JAVA_8, "TestSwitchInTry");
register(JAVA_21, "TestSwitchPatternMatchingJ21");
register(JAVA_21, "TestCastIntersectionJ21");
register(JAVA_16, "TestRecordLocal");
}

private void registerEntireClassPath() {
Expand Down
23 changes: 23 additions & 0 deletions testData/results/pkg/TestRecordLocal.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package pkg;

import java.util.List;

public class TestRecordLocal {
public Object test(List<Integer> list) {
record Rec(TestRecordLocal a, List<Integer> b) {
}

return new Rec(this, list);// 9
}
}

class 'pkg/TestRecordLocal' {
method 'test (Ljava/util/List;)Ljava/lang/Object;' {
4 9
5 9
9 9
}
}

Lines mapping:
9 <-> 10
11 changes: 11 additions & 0 deletions testData/src/java16/pkg/TestRecordLocal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package pkg;

import java.util.List;

public class TestRecordLocal {
public Object test(List<Integer> list) {
record Rec(TestRecordLocal a, List<Integer> b) {}

return new Rec(this, list);
}
}

0 comments on commit 9abb342

Please sign in to comment.