[
https://issues.apache.org/jira/browse/GROOVY-12140?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18094468#comment-18094468
]
ASF GitHub Bot commented on GROOVY-12140:
-----------------------------------------
Copilot commented on code in PR #2676:
URL: https://github.com/apache/groovy/pull/2676#discussion_r3540760490
##########
src/test/groovy/bugs/Groovy12140.groovy:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bugs
+
+import org.codehaus.groovy.control.CompilerConfiguration
+import org.junit.jupiter.api.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy12140 {
+
+ private static final String SCRIPT = '''
+ class W {
+ int num(int... xs) { 42 }
+ int val() { 42 }
+ char ch() { (char) 'a' }
+ boolean flag() { true }
+ }
+ def w = new W()
+ def name = 'val'
+ // dynamic-name calls dispatch reflectively via doMethodInvoke, in both
+ // compilation modes: primitive returns must box through the valueOf
+ // caches for identity (===) parity with directly dispatched calls
+ assert w."$name"() === 42
+ assert w."${'ch'}"() === Character.valueOf((char) 'a')
+ assert w."${'flag'}"() === Boolean.TRUE
+ // varargs methods use the reflective call-site variant under classic
+ assert w.num(1, 2) === 42
Review Comment:
The new normalization helper includes byte/short/long handling, but the
regression test currently only exercises int/char/boolean. Adding a few more
assertions would cover the additional primitive branches and reduce the risk of
a type-specific regression.
> box-identity divergence for primitive varargs with classic bytecode
> -------------------------------------------------------------------
>
> Key: GROOVY-12140
> URL: https://issues.apache.org/jira/browse/GROOVY-12140
> Project: Groovy
> Issue Type: Improvement
> Reporter: Paul King
> Priority: Major
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)