@@ -32,35 +32,6 @@ public void defaults(RecipeSpec spec) {
3232 .allSources (s -> s .markers (javaVersion (10 )));
3333 }
3434
35- @ Test
36- @ Issue ("https://github.com/openrewrite/rewrite-migrate-java/issues/550" )
37- void genericType () {
38- rewriteRun (
39- java (
40- """
41- import java.io.Serializable;
42-
43- abstract class Outer<T extends Serializable> {
44- abstract T doIt();
45- void trigger() {
46- T x = doIt();
47- }
48- }
49- """ ,
50- """
51- import java.io.Serializable;
52-
53- abstract class Outer<T extends Serializable> {
54- abstract T doIt();
55- void trigger() {
56- var x = doIt();
57- }
58- }
59- """
60- )
61- );
62- }
63-
6435 @ Nested
6536 class Applicable {
6637 @ DocumentExample
@@ -336,12 +307,86 @@ void m() {
336307 )
337308 );
338309 }
310+
311+ @ Test
312+ @ Issue ("https://github.com/openrewrite/rewrite-migrate-java/issues/550" )
313+ void genericType () {
314+ rewriteRun (
315+ java (
316+ """
317+ import java.io.Serializable;
318+
319+ abstract class Outer<T extends Serializable> {
320+ abstract T doIt();
321+ void trigger() {
322+ T x = doIt();
323+ }
324+ }
325+ """ ,
326+ """
327+ import java.io.Serializable;
328+
329+ abstract class Outer<T extends Serializable> {
330+ abstract T doIt();
331+ void trigger() {
332+ var x = doIt();
333+ }
334+ }
335+ """
336+ )
337+ );
338+ }
339339 }
340340 }
341341
342342 @ Nested
343343 class NotApplicable {
344344
345+ @ Test
346+ @ Issue ("https://github.com/openrewrite/rewrite-migrate-java/issues/608" )
347+ void genericTypeInStaticMethod () {
348+ /*
349+ * This can be migrated from `String string = Global.cast(o)` to `var string = Global.<String>cast(o)`.
350+ * But we decided to not migrate, because it is very unconventional Java.
351+ */
352+ rewriteRun (
353+ java (
354+ """
355+ package example;
356+
357+ class Global {
358+ static <T> T cast(Object o) {
359+ return (T) o;
360+ }
361+ }
362+ class User {
363+ public String test() {
364+ Object o = "Hello";
365+ String string = Global.cast(o);
366+ return string;
367+ }
368+ }
369+ """ ,
370+ """
371+ package example;
372+
373+ class Global {
374+ static <T> T cast(Object o) {
375+ return (T) o;
376+ }
377+ }
378+ class User {
379+ public String test() {
380+ var o = "Hello";
381+ String string = Global.cast(o);
382+ return string;
383+ }
384+ }
385+ """
386+ )
387+ );
388+ }
389+
345390 @ Test
346391 @ Issue ("https://github.com/openrewrite/rewrite-migrate-java/issues/551" )
347392 void arrayInitializer () {
@@ -350,7 +395,7 @@ void arrayInitializer() {
350395 java (
351396 """
352397 package com.example.app;
353-
398+
354399 class A {
355400 void m() {
356401 String[] dictionary = {"aa", "b", "aba", "ba"};
0 commit comments