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

Refine the generics presentation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      Nested generics should be shown as well, see the TODO in the following code:

      class Groovy8609Bug extends CompilableTestSupport {
          void testUpperBoundWithGenericsThroughWrongType2() {
              def errMsg = shouldFail '''
              @groovy.transform.CompileStatic
              public class A<T extends List<E>, E extends Map<String, Integer>> {
                  E getFirstRecord(T recordList) {
                      return recordList.get(0)
                  }
                  
                  static void main(args) {
                      def list = new ArrayList<HashMap<String, Long>>()
                      def record = new HashMap<String, Long>()
                      list.add(record)
                      def a = new A<ArrayList<HashMap<String, Integer>>, HashMap<String, Integer>>()
                      assert record.is(a.getFirstRecord(list))
                  }
              }
              '''
      
              // TODO we should print generics details, e.g. [Static type checking] - Cannot call A <ArrayList, HashMap<String, Integer>>#getFirstRecord(T) with arguments [java.util.ArrayList <HashMap<String, Long>>]
              assert errMsg.contains('[Static type checking] - Cannot call A <ArrayList, HashMap>#getFirstRecord(T) with arguments [java.util.ArrayList <HashMap>]')
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            daniel_sun Daniel Sun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: