Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5630

Java stub generator generates wrong cast for return value of generic method

    Details

      Description

      From org/gradle/util/HelperUtil.groovy:

      class HelperUtil {
          ...
          static <T extends Task> T createTask(Class<T> type) {
              ...
          }
          ...
      }
      

      Generated method stub in Groovy 1.8.6:

      public static <T extends org.gradle.api.Task> T createTask(java.lang.Class<T> type) { return (T)null;}
      

      This stub compiles fine.

      Generated method stub in Groovy 1.8.7:

      public static <T extends org.gradle.api.Task> T createTask(java.lang.Class<T> type) { return (org.gradle.api.Task)null;}
      

      This stub gives the following compile error:

      /swd/prj/gradle/subprojects/core/build/tmp/groovy-java-stubs/org/gradle/util/HelperUtil.java:22: error: incompatible types
      public static <T extends org.gradle.api.Task> T createTask(java.lang.Class<T> type) { return (org.gradle.api.Task)null;}
                                                                                                   ^
        required: T
        found:    Task
        where T is a type-variable:
          T extends Task declared in method <T>createTask(Class<T>)
      

        Attachments

          Activity

            People

            • Assignee:
              Guillaume Guillaume Delcroix
              Reporter:
              pniederw Peter Niederwieser
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: