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

Incorrect boxing of boolean primitive types

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.7
    • Fix Version/s: 2.4.8
    • Component/s: groovy-runtime
    • Labels:
      None

      Description

      A boolean primitive type seems to be boxed for no apparent reason. See the example below. The problem disappear when using @CompileStatic or if explicitly casting to (boolean).

      public class Demo {
      
         public void a(boolean a){
             System.out.println("boolean was called");
         }
      
         public void a(Object a){
             System.out.println("Object was called");
         }
      
      }
      class Groovy {
         static void main(String[] args) {
             def demo = new Demo()
             demo.a(true)
         }
      }
      

      Output:
      Object was called

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jwagenleitner John Wagenleitner
                Reporter:
                henri Henri Tremblay
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: