paulk-asert commented on code in PR #2499:
URL: https://github.com/apache/groovy/pull/2499#discussion_r3176058130
##########
src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java:
##########
@@ -998,4 +998,34 @@ public static Object bitwiseNegate(final Object value)
throws Throwable {
throw unwrap(gre);
}
}
+
+ /**
+ * GEP-15: dispatcher for compound-assignment operators in dynamic Groovy.
+ * If {@code receiver} responds to {@code assignName} with the supplied
argument,
+ * invoke it and return {@code receiver} (so the caller's STORE assigns
the same
+ * reference back, leaving the in-place mutation visible). Otherwise fall
back to
+ * {@code baseName} and return its result for the caller to assign.
+ */
+ public static Object compoundAssign(final Object receiver, final Object
arg,
+ final String assignName, final String
baseName) throws Throwable {
+ if (receiver != null) {
+ MetaClass mc = InvokerHelper.getMetaClass(receiver);
+ if (!mc.respondsTo(receiver, assignName, new
Object[]{arg}).isEmpty()) {
+ mc.invokeMethod(receiver, assignName, arg);
+ return receiver;
+ }
+ }
+ return InvokerHelper.invokeMethod(receiver, baseName, arg);
Review Comment:
fixed
--
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]