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

Static type checking error when assigning BigInteger child to BigInteger var from static context

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.9, 2.2.0-rc-3
    • Fix Version/s: 2.2.1
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      A static type checking error "[Static type checking] - Cannot assign value of type MyInteger to variable of type java.math.BigInteger" when assigning child class of BigInteger to a BigInteger variable. Occurs only from static context when @CompileStatic enabled. Does not occur for similar case for BigDecimal.

      Example:

      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);}
      }
      
      public class Foo {
      
        @groovy.transform.CompileStatic
        public static void run() {
          BigDecimal d = new MyDecimal("3.0");
          BigInteger i = new MyInteger("3"); //compile error: [Static type checking]
        }
      }
      
      Foo.run();
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: