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

STC: compiler error when using type parameter with extends

    XMLWordPrintableJSON

Details

    Description

      I have the following Groovy program.

      @groovy.transform.TypeChecked
      class Bar<L, T extends L> {
          T x;
          public Bar(T x) {
            this.x = x;
          }
      }
      

      Actual Behavior

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

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Bar.groovy: 5: [Static type checking] - Cannot assign value of type L to variable of type T
       @ line 5, column 16.
               this.x = x;
                        ^
      
      1 error
      

      Expected Behavior

      Compile successfully.

      Comment

      This bug is probably a regression because it compiles successfully with 3.0.8 and 4.0.0-alpha-3.

      Affected Version

      This programs have been tested with the compiler from the master (commit: c36c8bf3d24ce41e972e3f3e7a5763acf96f46b1).

      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: