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

Look up set (or better propertyMissing) via method signature

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.3.7
    • None
    • groovy-runtime
    • Java 7u45, Win64, IntelliJ IDEA CE 13.1.5

    Description

      The sample script causes this error:

      Caught: java.lang.IllegalArgumentException: argument type mismatch
      java.lang.IllegalArgumentException: argument type mismatch
      at Sample.setProperty(PropertyMissingProblem.groovy)
      at PropertyMissingProblem.run(PropertyMissingProblem.groovy:4)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

      The runtime tries to call the set(int,Object) signature of set. Instead it should pick a signature with String (or any of its interfaces or superclasses) as the first parameter.

      With the comments in the uploaded script removed, and the methods introduced by the category taking precedence, the output is:

      set String via use [hello = Howdy]
      set String via use [hello = Sat Oct 04 21:25:06 CEST 2014]

      Thus with the value to be assigned being a Date, the call still goes to the method with (String,String).

      So the type of the assigned value to an unknown property should also be observed when picking the right method signature of "set" (or better: propertyMissing). get/set and propertyMissing should treat different signatures like getAt/putAt do for operator overloading.

      Attachments

        1. PropertyMissingProblem.groovy
          0.7 kB
          Jochen Eddelbuettel

        Activity

          People

            Unassigned Unassigned
            eddelplus Jochen Eddelbuettel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: