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

STC doesn't find method reference on superclass

    XMLWordPrintableJSON

Details

    Description

      Java permits method references to specify a subclass in ContainingType, but the STC produces an error unless the exact declaring type is supplied.

      @Grab('io.vavr:vavr:0.10.4')
      import io.vavr.control.Option
      
      Option<String> supply() { Option.of('hello') }
      
      @groovy.transform.CompileStatic
      void test() {
        println supply().map(Option::toTry)
        //                   ^ declared on Value
      }
      
      test()
      

      produces

      Failed to find the expected method[toTry(java.lang.String)] in the type[io.vavr.control.Option] @ line 8, column 24.
           println supply().map(Option::toTry)
      

      (which also suggests that the STC, not traversing supertypes to find a ::toTry, has misinferred the signature).

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: