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

owner/delegatechain is broken for multiple delegates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.1-rc-1
    • None
    • None

    Description

      the following script should not fail:

      class A {
          def del;
          String toString(){del}
          def whoisThis() { return this }
          def met() { return "I'm the method inside '"+del+"'" }
       }
      
       def outerdel= new A(del: "outer delegate" )
       def innerdel= new A(del: "inner delegate")
      
       def cout= {
         assert delegate == outerdel
         assert delegate.whoisThis() == outerdel
         assert delegate.del == "outer delegate"
         assert delegate.met() == "I'm the method inside 'outer delegate'"
      
         assert whoisThis() == outerdel
         assert del == "outer delegate"
         assert met() == "I'm the method inside 'outer delegate'"
      
         def cin= {
             assert delegate == innerdel
             assert delegate.whoisThis() == innerdel
             assert delegate.del == "inner delegate"
             assert delegate.met() == "I'm the method inside 'inner delegate'"
      
             assert whoisThis() == outerdel
             assert del == "outer delegate"
             assert met() == "I'm the method inside 'outer delegate'"
         }
      
         cin.delegate= innerdel
         cin()
       }
      
       cout.delegate= outerdel
       cout() 
      

      it fails in the last three asserts for whoisThis() and met(), because the inner delegate is choosen instead of the outer

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            blackdrag Jochen Theodorou
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: