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

Regression, Compile static does not deduce Closure Type

    XMLWordPrintableJSON

Details

    Description

      The code below compiled successfully in 2.0.5

      in 2.1.1 we got compile error message:
      Groovyc: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type CTypeTest

      class CTypeTest {
      
        @CompileStatic
        public static void test1(String[] args) {
      
          // Cannot assign value of type java.lang.Object to variable of type CTypeTest
          CTypeTest s1 = cache  {
            return new CTypeTest();
          }
      
        }
      
      
        @CompileStatic
        static <T> T cache(Closure<T> closure) {
          return closure.call();
        }
      
      
      }
      

      Of-course this prevents us from upgrading to 2.1.1 (and using full indy feature)

      Thanks
      Boaz

      Attachments

        Activity

          People

            melix Cédric Champeau
            boaznahum Boaz Nahum
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: