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

StackOverflowError with mixins

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-rc-1
    • 1.6-rc-2, 1.7-beta-1
    • None
    • None

    Description

      The following script throws StackOverfloeError on the last line:

      class SampleA {
      public void foo()

      { println 'Original foo ' + receive('') }

      protected Object receive()

      { return "Message" }

      protected Object receive(Object param)

      { receive() + param }

      }

      class SampleB {}

      SampleB.metaClass {
      mixin SampleA

      foo = {->
      println 'New foo ' + receive('')
      }
      }

      final SampleA a = new SampleA()
      a.foo()

      final SampleB b = new SampleB()
      b.foo()

      Basically I'm trying to mix-in the SampleA functionality into SampleB and override the SampleA.foo() behavior at the same time. It works until I try to call the receive(String) method, which calls the receive(void) method in turn.

      Attachments

        Activity

          People

            ait Alex Tkachman
            roller_vaclav Vaclav Pech
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: