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

Cannot assign null to a variable with a bounded generic type

    XMLWordPrintableJSON

Details

    Description

      I have the following program

      final class Test<T extends Number> {
        final void m() {
          T v = null;
        }
      }
      

      Actual Behaviour

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 5: [Static type checking] - Cannot assign value of type <unknown parameter type> to variable of type T
       @ line 5, column 11.
             T v = null;
                   ^1 error
      
      

      Expected Behaviour

       

      Tested against master https://github.com/apache/groovy/commit/7a56d7130aaf7b5244fa5a82fa0505fb7509f51f

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: