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

ExpandoMetaClass append method does not throw an exception as per docs

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.7
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: