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

int reference seems to not use its wrapper class

    XMLWordPrintableJSON

    Details

      Description

      I have the following Groovy program

      @groovy.transform.TypeChecked
      class Foo {
        static Number foo() {
          def i = 10  // If I use: `Integer i = 10` it works
          return i
        }
      }
      

      Actual Behavior

      The program does not compile, and I get the following error.

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Test.groovy: 5: [Static type checking] - Cannot return value of type int on method returning type java.lang.Number
       @ line 5, column 12.
             return i
                    ^
      
      1 error
      

      Expected Behavior

      Compile successfully.

        Attachments

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              schaliasos Stefanos Chaliasos
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h