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

Compilation error with method receiving a java.lang.Byte

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.0.4
    • 2.0.6
    • Static compilation
    • None

    Description

      With Static Compilation enabled, if I try to call a method declared in a class that receives a parameter of type java.lang.Byte, the compilation fails, returning "[Static type checking] - Cannot find matching method".
      The same problem occurs when calling a method from inside another method, for instance:

      Test.gvy
      @groovy.transform.CompileStatic
      void testMethod(java.lang.Byte param){
      println(param)
      }
      
      @groovy.transform.CompileStatic
      void run (){
      testMethod(java.lang.Byte.valueOf("123"))
      }
      
      run()
      
      

      The problem seems to be in the "isAssignableTo" method from "org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.java" class, where ClassHelper.Byte_TYPE doesn't match the type received as an argument, probably because you are not using the redirect() method before comparing with the type that matters.

      Attachments

        1. Test.gvy
          0.2 kB
          Rodolfo Cruz

        Activity

          People

            melix Cédric Champeau
            rcruzjo Rodolfo Cruz
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: