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

org.codehaus.groovy.runtime.MetaClassHelper#getClassWithNullAndWrapper should return NullObject when accept null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.6
    • 5.0.0-alpha-3
    • groovy-runtime
    • None

    Description

      I have a extension class

      class NumberExtension {
          static Integer plus(Integer self, NullObject right) {
              return self;
          }
      }
      

      However

      1 + null

      will throw

      Ambiguous method overloading for method java.lang.Integer#plus
      

      Because org.codehaus.groovy.runtime.MetaClassHelper#getClassWithNullAndWrapper return null for null argument. Then org.codehaus.groovy.runtime.MetaClassHelper#calculateParameterDistance(java.lang.Class, org.codehaus.groovy.reflection.CachedClass) doesn't return 0 because null != NullObject.class

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              vipcxj XJ Chen
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 2h 20m
                  2h 20m