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

method resolution with parameter BigInteger fails for argument extending BigInteger

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.7, 2.1.9, 2.2.0-rc-3
    • 2.2.1
    • None
    • None

    Description

      When extending java.lang.BigInteger, using an obj of that child class as argument to a method with BigInteger parameter causes a MissingMethodException. Similar variations with BigDecimal or Number work fine.

      Sample:

      public class MyDecimal extends java.math.BigDecimal {
          public MyDecimal(String s) {super(s);}
      }
      
      public class MyInteger extends java.math.BigInteger {
          public MyInteger(String s) {super(s);}
      }
      
      class Expression {
          public int takeNumber(Number a) {return 1;}
          public int takeBigDecimal(BigDecimal a) {return 2;}
          public int takeBigInteger(BigInteger a) {return 3;}
      }
      
      Expression exp = new Expression();
      assert 1 == exp.takeNumber(new MyInteger("3")); //works fine: 1
      assert 2 == exp.takeBigDecimal(new MyDecimal("3.0")); //works fine: 2 
      assert 3 == exp.takeBigInteger(new MyInteger("3")); //MissingMethodException
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            blackdrag Jochen Theodorou
            mahool Mike Hoolehan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment