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

STC: empty map (or list) literal does not type check like emptyMap()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.12, 3.0.20
    • Static Type Checker
    • None

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test() {
        List<Integer> list = [].withDefault { 0 }
          // Cannot assign ListWithDefault<? extends Object> to List<Integer>
        Map<String,Integer> map = [:].withDefault { 1 }
          // Cannot assign Map<Object, ? extends Object> to Map<String, Integer>
      }
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: