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: Open
    • Major
    • Resolution: Unresolved
    • 2.5.6
    • None
    • 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

              Unassigned Unassigned
              vipcxj XJ Chen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 20m
                  2h 20m