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

STC cannot compile program with multiple bounded type parameters

    XMLWordPrintableJSON

Details

    Description

      I have the following Groovy program.

      @groovy.transform.CompileStatic
      class Main<I extends B<Character>> {
        void main() {
          C<I> x = (C<I>) null
          x.foo().bar(null)
        }
      }
      
      class A<I, E extends I>  {
        void bar(E y) {}
      }
      
      class B<T> {}
      
      class C<S extends B<Character>> {
        A<S, ? extends S> foo() { (A<S, ? extends S>) null}
      }
      
      

      Actual Behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 4: [Static type checking] - Cannot call A#bar(B) with arguments [<unknown parameter type>]
       @ line 4, column 5.
             x.foo().bar(null)
             ^
      
      1 error
      

      Expected behavior

      Compile successfully.

      Comment

      This should be a regression bug because groovyc 4.0.0-alpha-3 compiles the program successfully

      Affected Version

      master (commit: e453db968df3753dc6c26d51168b944137c8e4b1)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: