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

Type checker doesn't infer property type if coming from a generified getter

    XMLWordPrintableJSON

Details

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

    Description

      If someone uses the property notation to get the key or the value of a map entry, the property type is not inferred properly. The workaround is to use a getter instead.

      Test case:

      Map.Entry<Date, Integer> entry
      
      @ASTTest(phase=INSTRUCTION_SELECTION, value={
          assert node.getNodeMetaData(INFERRED_TYPE) == make(Date)
      })
      def k = entry?.key
      
      @ASTTest(phase=INSTRUCTION_SELECTION, value={
          assert node.getNodeMetaData(INFERRED_TYPE) == Integer_TYPE
      })
      def v = entry?.value
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: