daniellansun commented on code in PR #2822:
URL: https://github.com/apache/groovy/pull/2822#discussion_r3834991427


##########
src/main/java/org/codehaus/groovy/vmplugin/v8/Selector.java:
##########
@@ -1314,11 +1317,8 @@ public void setGuards(Object receiver) {
                     handle = MethodHandles.guardWithTest(test, handle, 
fallback);
                 }
             } else if (Arrays.stream(pt).anyMatch(nonFinalOrNullUnsafe)) {
-                MethodHandle test = SAME_CLASSES
-                        
.bindTo(Arrays.stream(args).map(Object::getClass).toArray(Class[]::new))
-                        .asCollector(Object[].class, pt.length)
-                        .asType(MethodType.methodType(boolean.class, pt));
-                handle = MethodHandles.guardWithTest(test, handle, fallback);
+                handle = MethodHandles.guardWithTest(
+                        Selector.sameClassesGuard(args, pt), handle, fallback);

Review Comment:
   Agreed.
   
   - **Arity 0:** `anyMatch` on an empty `pt` is already false, and a receiver
     is always present, so this branch never ran for a parameterless handle.
     The helper no longer special-cases `n == 0` with a constant-`true`
     combinator. If it is called with no parameters it falls through to an
     empty collector (returns `true`); that path is tested. No no-op
     `guardWithTest` is installed on the live call site.
   - **`MethodType`:** the helper now takes `handle.type()` and uses
     `callType.changeReturnType(boolean.class)` for the guard signature,
     including primitive slots (GROOVY-11782).
   - **`ClassValue` / call-site index:** agreed, that is a different change
     (an extra argument on the bootstrap, a table on the host class). Not
     something I would mix into this PR.



-- 
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]

Reply via email to