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

STC: inconsistent support for assignment of list literals

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-alpha-3
    • None
    • None

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test() {
        List<String> a = [] // okay
        Set<String> b = [] // okay
        Deque<String> c = [] // GroovyCastException at runtime
        Deque<String> d = [1,2,3] // error for unknown constructor (interfaces don't have them) and error for incompatible generics
        ArrayDeque<String> e = [123] // ArrayDeque(int numElements); error for incompatible generics (bad)
        Set<String> f = ['foo', 'bar', 'foo'] // error for unknown constructor (castToType would handle this at runtime if allowed) and error for incompatible generic types (wrong)
      }
      

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h