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

Type checking of array initializer expressions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.8, 4.0.0-beta-1, 2.5.22
    • None
    • None

    Description

      This is a follow up of https://issues.apache.org/jira/browse/GROOVY-9985

      After the bug fix of the above GROOVY-9985, STC indeed catches the type error in the following program

      public class Main {
        public static void main(String[] args) {
          Integer[] arr = new Integer[] {"fd" 1}; // compile-time error here
          Integer y = arr[0];
        }
      }
      

      However, STC still is not able to catch type errors like the following

      public class Main {
        public static void main(String[] args) {
          Integer[] arr = new Integer[] {new Object(), 1}; // STC misses the error here
          Integer y = arr[0]; // ClassCastException at runtime
        }
        
      }
      

       

      Attachments

        Activity

          People

            emilles Eric Milles
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: