File tree 3 files changed +151
-1
lines changed
src/delombok/lombok/delombok 3 files changed +151
-1
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (C) 2016-2021 The Project Lombok Authors.
2
+ * Copyright (C) 2016-2024 The Project Lombok Authors.
3
3
*
4
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
* of this software and associated documentation files (the "Software"), to deal
@@ -263,6 +263,14 @@ private boolean suppress(JCTree tree) {
263
263
return false ;
264
264
}
265
265
266
+ private void print (Name name ) {
267
+ if (name .isEmpty ()) {
268
+ print ("_" );
269
+ } else {
270
+ print (name .toString ());
271
+ }
272
+ }
273
+
266
274
private void print (CharSequence s ) {
267
275
boolean align = needsAlign ;
268
276
if (needsNewLine && !onNewLine ) println ();
@@ -1722,6 +1730,8 @@ public void visitTypeBoundKind(TypeBoundKind tree) {
1722
1730
printPatternCaseLabel (tree );
1723
1731
} else if (className .endsWith ("$JCRecordPattern" )) { // Introduced in JDK19
1724
1732
printRecordPattern (tree );
1733
+ } else if (className .endsWith ("$JCAnyPattern" )) { // Introduced in JDK22
1734
+ print ("_" );
1725
1735
} else {
1726
1736
throw new AssertionError ("Unhandled tree type: " + tree .getClass () + ": " + tree );
1727
1737
}
Original file line number Diff line number Diff line change
1
+ // version 22:
2
+ import java .util .Arrays ;
3
+ import java .util .Scanner ;
4
+ import java .util .stream .Stream ;
5
+
6
+ record Box <T >(T content ) {
7
+ }
8
+
9
+ record Pair <T , U >(T first , U second ) {
10
+ }
11
+
12
+ public class UnnamedVariables {
13
+ void enhancedLoop () {
14
+ for (String _ : Arrays .asList ("" )) {
15
+ }
16
+ }
17
+
18
+ void initializationInForLoop () {
19
+ for (int i = 0 , _ = Integer .MAX_VALUE ; i < 10 ; i ++) {
20
+ }
21
+ }
22
+
23
+ void assignment () {
24
+ var _ = 1 ;
25
+ }
26
+
27
+ void catchBlock () {
28
+ try {
29
+ } catch (Exception _) {
30
+ }
31
+ }
32
+
33
+ void tryWithResources () {
34
+ try (var _ = new Scanner ("" )) {
35
+ }
36
+ }
37
+
38
+ void lambda () {
39
+ Stream .of (1 ).forEach (_ -> {
40
+ });
41
+ }
42
+
43
+ Object switchStatement (Object o ) {
44
+ return switch (o ) {
45
+ case String _ , Integer _ -> o ;
46
+ case Long _ -> o ;
47
+ default -> o ;
48
+ };
49
+ }
50
+
51
+ void recordPattern (Object o ) {
52
+ if (o instanceof Pair (Box _ , Box (Integer _ ))) {
53
+ }
54
+ if (o instanceof Box (String _ )) {
55
+ }
56
+ if (o instanceof Box (var _ )) {
57
+ }
58
+ if (o instanceof Box (_)) {
59
+ }
60
+ }
61
+
62
+ Object recordPatternSwitch (Object o ) {
63
+ return switch (o ) {
64
+ case Box (String _ ), Box (Integer _ ) -> o ;
65
+ case Box (Long _ ) -> o ;
66
+ case Box (_) -> o ;
67
+ default -> o ;
68
+ };
69
+ }
70
+ }
Original file line number Diff line number Diff line change
1
+ // version 22:
2
+ import java .util .Arrays ;
3
+ import java .util .Scanner ;
4
+ import java .util .stream .Stream ;
5
+
6
+ record Box <T >(T content ) {
7
+ }
8
+
9
+ record Pair <T , U >(T first , U second ) {
10
+ }
11
+
12
+ public class UnnamedVariables {
13
+ void enhancedLoop () {
14
+ for (String _ : Arrays .asList ("" )) {
15
+ }
16
+ }
17
+
18
+ void initializationInForLoop () {
19
+ for (int i = 0 , _ = Integer .MAX_VALUE ; i < 10 ; i ++) {
20
+ }
21
+ }
22
+
23
+ void assignment () {
24
+ var _ = 1 ;
25
+ }
26
+
27
+ void catchBlock () {
28
+ try {
29
+ } catch (Exception _) {
30
+ }
31
+ }
32
+
33
+ void tryWithResources () {
34
+ try (var _ = new Scanner ("" )) {
35
+ }
36
+ }
37
+
38
+ void lambda () {
39
+ Stream .of (1 ).forEach (_ -> {
40
+ });
41
+ }
42
+
43
+ Object switchStatement (Object o ) {
44
+ return switch (o ) {
45
+ case String _ , Integer _ -> o ;
46
+ case Long _ -> o ;
47
+ default -> o ;
48
+ };
49
+ }
50
+
51
+ void recordPattern (Object o ) {
52
+ if (o instanceof Pair (Box _ , Box (Integer _ ))) {
53
+ }
54
+ if (o instanceof Box (String _ )) {
55
+ }
56
+ if (o instanceof Box (var _ )) {
57
+ }
58
+ if (o instanceof Box (_)) {
59
+ }
60
+ }
61
+
62
+ Object recordPatternSwitch (Object o ) {
63
+ return switch (o ) {
64
+ case Box (String _ ), Box (Integer _ ) -> o ;
65
+ case Box (Long _ ) -> o ;
66
+ case Box (_) -> o ;
67
+ default -> o ;
68
+ };
69
+ }
70
+ }
You can’t perform that action at this time.
0 commit comments