GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-1131

Type inferencing should work inside of DGM methods called with non-collection arguments

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.2.Release
    • Fix Version/s: 2.5.2.Release
    • Component/s: Inferencing Engine
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The following will infer the type from the list:

      [1].each {
          it
      }
      

      however, the following will not:

      1.each {
          it
      }
      

        Activity

        Hide
        Andrew Eisenberg added a comment -

        I didn't even know that was a valid expression. I'll have a look at the meaning of each to see how it really works and then I can make some changes to how the inferencing engine interprets it.

        Show
        Andrew Eisenberg added a comment - I didn't even know that was a valid expression. I'll have a look at the meaning of each to see how it really works and then I can make some changes to how the inferencing engine interprets it.
        Hide
        Andrew Eisenberg added a comment -

        I see that in org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.asCollection(Object), the last line is this:

                else {
                    // let's assume it's a collection of 1
                    return Collections.singletonList(value);
                }
        

        So, it appears this is a nice heuristic for the inferencing engine, that if a target of an iteration block is not itself iterable, then just return the type of self.

        Show
        Andrew Eisenberg added a comment - I see that in org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.asCollection(Object) , the last line is this: else { // let's assume it's a collection of 1 return Collections.singletonList(value); } So, it appears this is a nice heuristic for the inferencing engine, that if a target of an iteration block is not itself iterable, then just return the type of self.
        Hide
        Andrew Eisenberg added a comment -

        Fixed with regression tests.

        Show
        Andrew Eisenberg added a comment - Fixed with regression tests.
        Andrew Eisenberg made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Andrew Eisenberg [ werdna ]
        Fix Version/s 2.5.2.Release [ 17434 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Andrew Eisenberg
            Reporter:
            Bob Tiernay
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: