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

unable to reference one static closure from another without class name prefix

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6, 2.4.3
    • 4.0.0-alpha-3
    • Compiler
    • None
    • groovy 1.6 java 1.6

    Description

      I've hit an issue in groovy 1.6 where one statically defined closure can't seem to access another static closure in the same class without prefixing the actual name of the class on the call to the closure.

      This test case demonstrates the issue:

      #! /usr/bin/env groovy

      class Foo {
      static first =

      { val -> "first $val" }

      // works as expected
      static second =

      { Foo.first( "second" ) }

      // doesn't work, apparently "first" is not in scope, is this expected behavior?
      static third =

      { first( "third" ) }

      }

      assert "first second" == Foo.second() // OK in 1.6
      assert "first third" == Foo.third() // blows up in 1.6!

      Attachments

        1. 3422_v15X.txt
          8 kB
          Roshan Dawrani

        Activity

          People

            Unassigned Unassigned
            tednaleid Ted Naleid
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: