eric-milles commented on a change in pull request #1674:
URL: https://github.com/apache/groovy/pull/1674#discussion_r780607867
##########
File path: src/main/java/groovy/lang/MetaClassImpl.java
##########
@@ -2085,73 +2089,65 @@ public void setProperty(Object object, Object newValue)
{
checkInitalised();
//----------------------------------------------------------------------
- // turn getProperty on a Map to get on the Map itself
+ // getter
//----------------------------------------------------------------------
- if (!isStatic && this.isMap) {
- return new MetaProperty(name, Object.class) {
- @Override
- public Object getProperty(Object object) {
- return ((Map) object).get(name);
- }
-
- @Override
- public void setProperty(Object object, Object newValue) {
- throw new UnsupportedOperationException();
- }
- };
- }
-
Tuple2<MetaMethod, MetaProperty> methodAndProperty =
createMetaMethodAndMetaProperty(sender, theClass, name, useSuper, isStatic);
MetaMethod method = methodAndProperty.getV1();
-
//----------------------------------------------------------------------
- // getter
-
//----------------------------------------------------------------------
- MetaProperty mp = methodAndProperty.getV2();
+ if (method == null || "class".equals(name) || (isMap &&
"empty".equals(name))) {
Review comment:
Why is it better to extract? `getProperty` and
`getEffectiveMetaProperty` are essentially the same general structure, only
differing in a few details. I don't really have the energy to extract the true
repeated structure(s). You can follow the two methods and see the parallel, so
I think it is decent in this state.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]