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

GString doesn't call correct toString method when it's been changed via the metaClass mechanism

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.5.4
    • None
    • None
    • None
    • linux
    • Patch

    Description

      This is best shown by a small example. I've attached a trivial patch as well.

      class A {
      String toString()

      { "unchanged"; }

      }

      A.metaClass.toString = { ->
      "changed";
      }

      def a = new A();
      println a.toString();
      println "${a}";

      brandon@Brandon:~/localtmp/groovy-1.5.4$ unset GROOVY_HOME
      brandon@Brandon:~/localtmp/groovy-1.5.4$ groovy-unpatched test.groovy
      changed
      unchanged
      brandon@Brandon:~/localtmp/groovy-1.5.4$ groovy test.groovy
      changed
      changed

      Attachments

        1. gstring.patch
          0.4 kB
          brandon niemczyk

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bniemczyk brandon niemczyk
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: