groovy
  1. groovy
  2. GROOVY-2746

Static import of method with default parameter value: MissingMethodException

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.4
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Java 1.6, Ubuntu and Windows XP
    • Testcase included:
      yes
    • Number of attachments :
      3

      Description

      A static method with a default parameter is not found, when it is imported statically and called without prefixing his class:

      === test.groovy ===

      import static Settings.*
      import static ConsoleUI.*

      class Settings
      {
      static void initialize()

      { writeln("working", 100) writeln("failing") }

      }

      class ConsoleUI
      {
      static void writeln(String s, int delay = 0)

      { sleep delay println s }

      }

      Settings.initialize()

      === Output ===

      working
      Caught: groovy.lang.MissingMethodException: No signature of method: static Settings.writeln() is applicable for argument types: (java.lang.String) values:

      {"failing"}

      at Settings.initialize(test.groovy:8)
      at test.run(test.groovy:20)
      at test.main(test.groovy)

      Exited: 256

      1. 2746_v15x_v2.diff
        2 kB
        Roshan Dawrani
      2. 2746_v16x_v2.diff
        2 kB
        Roshan Dawrani
      3. 2746_v17x_v2.diff
        2 kB
        Roshan Dawrani

        Issue Links

          Activity

          Hide
          Roshan Dawrani added a comment -

          Attaching the newer set of patches with the following changes based on the comments:

          1) Conditions modified to not use negation.

          2) No assumption that parameters with default values will only be specified at the end in parameter list of a static method.

          rgds,
          Roshan

          Show
          Roshan Dawrani added a comment - Attaching the newer set of patches with the following changes based on the comments: 1) Conditions modified to not use negation. 2) No assumption that parameters with default values will only be specified at the end in parameter list of a static method. rgds, Roshan
          Hide
          blackdrag blackdrag added a comment -

          much better now

          Show
          blackdrag blackdrag added a comment - much better now
          Hide
          Roshan Dawrani added a comment -

          Thank you. Trying negation had a side-advantage though. I have some insider information on one thing that you can get wrong in reviewing code

          Show
          Roshan Dawrani added a comment - Thank you. Trying negation had a side-advantage though. I have some insider information on one thing that you can get wrong in reviewing code
          Hide
          Roshan Dawrani added a comment -

          I had moved duplicate isStatic() calls to one place in hasPossibleStaticMethod. Missed doing that in 1.7 patch. So, just re-attaching that patch.

          Sorry for a little clutter.

          Show
          Roshan Dawrani added a comment - I had moved duplicate isStatic() calls to one place in hasPossibleStaticMethod. Missed doing that in 1.7 patch. So, just re-attaching that patch. Sorry for a little clutter.
          Hide
          blackdrag blackdrag added a comment -

          patch applied

          Show
          blackdrag blackdrag added a comment - patch applied

            People

            • Assignee:
              blackdrag blackdrag
              Reporter:
              Ivan Dolvich
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: