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

STC loses generic information on method references

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.17
    • 4.0.18, 3.0.21
    • Static Type Checker
    • None

    Description

      In the following code, the correct return type of Map.Entry::getKey is K = String, but the STC loses track of it and returns Object, leading to downstream type mismatches.

      @CompileStatic
      class Repro {
          void repro(Map<String, String> input) {
              var keys = input.entrySet().stream()
                  .map(Map.Entry::getKey)
                  .toSet()
      
              consume(keys)
          }
      
          static void consume(Set<String> keys) {}
      }
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: