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

groovy3: setProperty does not work in sub classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-rc-2
    • None
    • None

    Description

      The following code runs in groovy2, but not 3

      class A {
          def a = "a";
      }
      
      class B extends A {
          
      }
      
      class C extends B {
          void setProperty(String name, Object value) {
              super.setProperty(name, value);
          }
      }
      
      def newC = new C();
      newC.setProperty("a", "b");
      newC.a
       

      groovy 3 output:

      groovy.lang.MissingMethodException: No signature of method: B.setProperty() is applicable for argument types: (String, String) values: [a, b]
      Possible solutions: hasProperty(java.lang.String), getProperties()
      	at C.setProperty(ConsoleScript10:11)
      	at ConsoleScript10.run(ConsoleScript10:16)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
      

      Attachments

        Activity

          People

            emilles Eric Milles
            howardzzhang Howard
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: