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

STC: error when passing a type parameter in type constructor

    XMLWordPrintableJSON

Details

    Description

      I have the following Groovy program.

      @groovy.transform.TypeChecked
      class Test<T> {
        public void foo() {
          Foo<T, Long> x = new Foo<T, Long>(new Bar<T, Long>());
        }
      }
      
      class Foo<X, T> {
        public Foo(Bar<X, T> y) {}
      }
      
      class Bar<X, T> {}
      
      

      Actual Behavior

      The program does not compile, and I get the following error.

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Test.groovy: 4: [Static type checking] - Cannot call Foo#<init>(Bar<T, java.lang.Long>) with arguments [Bar<T, java.lang.Long>]
       @ line 4, column 22.
             Foo<T, Long> x = new Foo<T, Long>(new Bar<T, Long>());
                              ^
      
      1 error
      

      Expected Behavior

      Compile successfully.

      Affected Version

      This programs have been tested with the compiler from the master (commit: c36c8bf3d24ce41e972e3f3e7a5763acf96f46b1), 4.0.0-alpha-3, and 3.0.8.

      Attachments

        Activity

          People

            emilles Eric Milles
            schaliasos Stefanos Chaliasos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: