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

ExpandoMetaClass append method does not throw an exception as per docs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4.7
    • None
    • None

    Description

      I was reading the docs when I came across "Note that the left shift operator is used to append a new method. If the method already exists an exception will be thrown."

      I decided to try it via the below program. There was no exception. I am using groovy 2.3.8

      class A {
      }
      A.metaClass.hello = {
        "hello superclass"
      }
      
      class B extends A {
      }
      B.metaClass.hello << {
        "hello subclass"
      }
      
      B.metaClass.hello << {
        "hello subclass"
      }
      
      new B().hello()
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            anshbansal Aseem Bansal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: