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

Error adding a trait to a Map

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.0-rc-2, 2.3.0
    • 2.3.1
    • None

    Description

      With this code:

      trait Extra {
      String extra()

      { "I'm an extra method" }

      }

      def extraList = [] as Extra
      assert extraList.extra() == "I'm an extra method"

      def extraMap = [:] as Extra
      assert extraMap.extra() == "I'm an extra method"

      I get error:
      Caught: java.lang.UnsupportedOperationException
      java.lang.UnsupportedOperationException
      at com.sun.proxy.$Proxy8.extra(Unknown Source)
      at Extra$extra$0.call(Unknown Source)
      at Runtime.run(Runtime.groovy:9)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

      Attachments

        Activity

          People

            melix Cédric Champeau
            grooscript Jorge Franco
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: