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

STC doesn't resolve zero-argument method references in nested generics

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.0.4
    • 4.0.5, 3.0.13
    • Static Type Checker
    • None

    Description

      I have a rather mundane Streams pipeline trying to group some items by a particular property.

      @CompileStatic
      class GroovyExample {
          String category
          String title
      
          static Object organize(Collection<GroovyExample> examples) {
              examples.stream()
                  .collect(groupingBy(GroovyExample::getCategory))
          }
      }
      

      This produces

      Failed to find the expected method[getCategory(java.lang.Object)] in the type[GroovyExample]
      

      This feels similar to GROOVY-9803 in that the apparent problem is a result of a nested generic call that, while unambiguous according to the JLS rules, doesn't get propagated tightly enough for the STC to correctly recognize that the target type is GroovyExample and thus the zero-argument method is the correct resolution.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            emilles Eric Milles
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment