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

Method reference doesn't accept subtypes of argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.6
    • 3.0.7, 4.0.0-alpha-2
    • Compiler
    • None

    Description

      When using a method reference such as HasId::getId, the compiler implements the request by generating a MethodClosure. However, the closure accepts only the exact type of the reference, not subtypes. All compile-time checks pass, but the closure throws MissingMethodException at runtime with the message

      No signature of method: org.codehaus.groovy.runtime.MethodClosure.getId() is applicable for argument types: (com.example.ClassWithId)
      

      Attachments

        1. Groovy9814.groovy
          1 kB
          Christopher Smith

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m