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

Cannot override methods via metaclass that are part of an interface implementation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.6.2
    • 4.0.0-rc-2
    • groovy-runtime
    • None

    Description

      The following works...

      class T {
             def doIt() { true }
      }
      
      def t = new T()
      
      assert t.doIt()
      t.metaClass.doIt = { -> false }
      assert !t.doIt()
      

      But this fails...

      interface I {
             def doIt()
      }
      
      class T implements I {
             def doIt() { true }
      }
      
      def t = new T()
      
      assert t.doIt()
      t.metaClass.doIt = { -> false }
      assert !t.doIt()
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              ldaley Luke Daley
              Votes:
              24 Vote for this issue
              Watchers:
              22 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: