You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2020/07/05 02:25:18 UTC

[GitHub] [groovy] paulk-asert edited a comment on pull request #1296: GROOVY-9618: index "static getX()" as "X" if class field X also exists

paulk-asert edited a comment on pull request #1296:
URL: https://github.com/apache/groovy/pull/1296#issuecomment-653833254


   I think I might roll this back for the time being. Sorry for not getting time to review earlier.
   
   For this class:
   ```
   class A {
     private Y = 1
     def getY() { 2 }
     private static X = 1
     static getX() { 2 }
     static class B { }
     class Z { }
   }
   class AB extends A.B {
     def m() {
       println X
       println x
     }
   }
   class AZ extends A.Z {
     AZ() {
       super(new A())
     }
     def n() {
       println Y
       println y
     }
   }
   new AB().m()
   new AZ().n()
   new A().with {
       println Y
       println y
       println X
       println x
   }
   ```
   In 3.0.4 we get:
   ```
   1
   2
   1
   2
   1
   2
   1
   2
   ```
   But after this breaking change we get:
   ```
   2
   MPE: No such property: x for class: A
   1
   2
   1
   2
   2
   MPE: No such property: x for class: A
   ```
   To me this is an edge case from the JavaBean spec which isn't clear.
   Some folks might expect "1" from "print X" and "2" from "print x". It can be argued from both points of view.
   
   I am not necessarily against some kind of change here and the dual index idea might be close to what we need, but the above is inconsistent as well as likely to break some existing code.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org