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

Invalid type substitution when encountering bounded type parameter and the diamond operator

    XMLWordPrintableJSON

Details

    Description

      This bug is a regression.

      I have the following program:

      class A<T, Y> {
        B<Y> f;
        A(B<Y> x, T y) {}
      }
      
      class B<T> {
        void m(T x) {}
      }
      
      class Test {
        <T extends Number> void test() {
          def x = new B<T>();
          new A<>(x, "").f.m((T) null);
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 13: [Static type checking] - Cannot find matching method B#m(T). Please check if the declared type is correct and if the method exists.
       @ line 13, column 5.
             new A<>(x, "").f.m((T) null);
             ^
      
      1 error
      

      Expected behaviour

      Compile successfully

      Tested against master (commit: a976ecdee1f17f7fafc55767de2d857c44d44697)

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              theosot Thodoris Sotiropoulos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: