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

Type checker incorrectly selecting DGM return type instead of actual return type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1
    • Static Type Checker
    • None

    Description

      The following code:

      import java.lang.reflect.Array
      
      @groovy.transform.CompileStatic
      def arrayTest() {
         Object[] joinedArray = (Object[]) Array.newInstance(Integer.class, 10);
      }
      

      Results in

      [Static type checking] - Inconvertible types: cannot cast java.lang.reflect.Array to [Ljava.lang.Object;
       at line: 5, column: 27
      

      The DGM newInstance method is being used instead of http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Array.html#newInstance(java.lang.Class,%20int)

      Attachments

        Issue Links

          Activity

            People

              melix Cédric Champeau
              graemerocher Graeme Rocher
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: