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

Call behavior on enums is inconsistent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.7
    • 1.6.1, 1.5.8, 1.7-beta-1
    • None
    • None
    • XP, cygwin, JRE 1.6.0

    Description

      A call method on an enum can be used within a for loop, but not otherwise. This is kind of odd, and it might be better to disable the for loop behavior if it's not reasonable to fix in general.

       
      
      enum Foo {
          A({ println("A") }),
          B({ println("B") })
          Foo(Closure c) {
            call = c
          }
          final Closure call
      }
      
      // works
      for (f in Foo) {
         f()
      }
      
      // works
      Foo.A.call()
      
      // doesn't work
      Foo.A()
      
      // doesn't work
      a=Foo.A
      a()
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            cityhall Chris Currivan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: