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

Can not call a java parameterized type method from groovy with java enum. Compile error

    XMLWordPrintableJSON

Details

    Description

      Java:

      import java.io.Serializable;
      
      public class aJavaClass<A extends Serializable>  {
      
          private aJavaClass(final A inA) {
              System.out.println("Hello");
          }
      
          public static <A extends Serializable> aJavaClass<A> create(final A inA) {
              return new aJavaClass<>(inA);
          }
      
          public enum aEnum {
              entry1,
          }
      }

      Groovy calling class:

      import groovy.transform.CompileStatic
      
      import aJavaClass
      
      @CompileStatic
      class aCallingGroovyClass {
      
          static void main(String[] args) {
              aJavaClass.create(aJavaClass.aEnum.entry1)
          }
      }

      try compiling get:

      Error:(10, 9) Groovyc: [Static type checking] - Cannot call <A extends java.io.Serializable> aJavaClass#create(A) with arguments [aJavaClass$aEnum]

      Replace the method arg aJavaClass.aEnum.entry1 with non enum, say '1' no quotes, code compiles and runs.

      Attachments

        Activity

          People

            emilles Eric Milles
            SpeedBoat Stuart Adamson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: