Commit 9e118a4
authored
Add explicit casts for visitor visit() return type (#1049)
* Add explicit casts for visitor `visit()` return type
The `visit()` method on OpenRewrite visitors now returns `J` rather
than the specific subtype. Add explicit casts at affected call sites:
- `RefineSwitchCases` — cast to `J.Switch`
- `IfElseIfConstructToSwitch` — cast to `J.Switch`
- `LombokValueToRecord` — cast to `J.ClassDeclaration`
- `RemoveEmbeddableId` — cast to `J.ClassDeclaration`
Also fix `MoveAnnotationToArrayType` missing `@Nullable` import by
adding `org.jspecify.annotations.Nullable` and adjusting type-use
annotation placement.
* Revert @nullable annotation changes in MoveAnnotationToArrayType
* Add missing @nullable import in MoveAnnotationToArrayType
* Avoid constructor calls in RemovedModifierAndConstantBootstrapsConstructors test
The core ChangeMethodTargetToStatic recipe now matches constructor calls
with the wildcard pattern, incorrectly converting `new Modifier()` to
`Modifier.Modifier()`. Pass instances as parameters instead to avoid
triggering the constructor matching.1 parent 41373e1 commit 9e118a4
7 files changed
Lines changed: 13 additions & 20 deletions
File tree
- src
- main
- java/org/openrewrite/java/migrate
- javax
- jspecify
- lang
- lombok
- resources/META-INF/rewrite
- test/java/org/openrewrite/java/migrate
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
912 | | - | |
913 | | - | |
| 912 | + | |
914 | 913 | | |
915 | 914 | | |
916 | 915 | | |
917 | 916 | | |
918 | 917 | | |
919 | 918 | | |
920 | | - | |
921 | | - | |
| 919 | + | |
922 | 920 | | |
923 | 921 | | |
924 | 922 | | |
| |||
929 | 927 | | |
930 | 928 | | |
931 | 929 | | |
932 | | - | |
933 | | - | |
| 930 | + | |
934 | 931 | | |
935 | 932 | | |
936 | 933 | | |
937 | 934 | | |
938 | 935 | | |
939 | 936 | | |
940 | | - | |
941 | | - | |
| 937 | + | |
942 | 938 | | |
943 | 939 | | |
944 | 940 | | |
| |||
Lines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
52 | | - | |
| 50 | + | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
| |||
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
64 | | - | |
65 | | - | |
| 62 | + | |
66 | 63 | | |
67 | 64 | | |
68 | 65 | | |
69 | 66 | | |
70 | 67 | | |
71 | 68 | | |
72 | | - | |
73 | | - | |
| 69 | + | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
| |||
0 commit comments