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

Unable to resolve field from a bounded type parameter

    XMLWordPrintableJSON

Details

    Description

      I have the following code

      
      import java.util.function.Supplier;
      
      
      class A {
        public String x;
      }
      
      
      public class B<T extends A, X extends Supplier<T>> {
        void test(T p) {
          p.x = "str";
        } 
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 12: [Static type checking] - No such property: x for class: T
       @ line 12, column 5.
             p.x = "str";
             ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Notes: This error occurs only when there is a second bounded type parameter in class B, and the first type parameter (i.e., T) is used there.

      Tested against master (commit: 2095b9eb3b73c5bcf27625395c24fa5210890443)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: