You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/09/07 05:05:13 UTC
[groovy] branch master updated: GROOVY-9706: Groovy 3.0.5 varargs
[Static type checking] - Cannot find matching method
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 6af97ad GROOVY-9706: Groovy 3.0.5 varargs [Static type checking] - Cannot find matching method
6af97ad is described below
commit 6af97ad0f26ab45b306cfe26e459870a1d1a2a88
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Sep 7 15:05:01 2020 +1000
GROOVY-9706: Groovy 3.0.5 varargs [Static type checking] - Cannot find matching method
---
.../transform/stc/StaticTypeCheckingSupport.java | 2 +-
src/test/groovy/bugs/Groovy9706.groovy | 40 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index cb164ad..b569fc9 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -430,7 +430,7 @@ public abstract class StaticTypeCheckingSupport {
ClassNode lastParamType = parameters[parameters.length - 1].getType();
ClassNode ptype = lastParamType.getComponentType();
ClassNode arg = argumentTypes[argumentTypes.length - 1];
- if (isNumberType(ptype) && isNumberType(arg) && !ptype.equals(arg)) return -1;
+ if (isNumberType(ptype) && isNumberType(arg) && !getWrapper(ptype).equals(getWrapper(arg))) return -1;
return isAssignableTo(arg, ptype) ? min(getDistance(arg, lastParamType), getDistance(arg, ptype)) : -1;
}
diff --git a/src/test/groovy/bugs/Groovy9706.groovy b/src/test/groovy/bugs/Groovy9706.groovy
new file mode 100644
index 0000000..19ca427
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy9706.groovy
@@ -0,0 +1,40 @@
+/*
+ * 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 groovy.bugs
+
+import groovy.test.GroovyTestCase
+
+class Groovy9706 extends GroovyTestCase {
+ void testVarargsPrimitive() {
+ assertScript '''
+ @groovy.transform.TypeChecked
+ class Foo {
+ private vfunc(String s, int... ints) {
+ "$s ${ints[0]}"
+ }
+ String caller() {
+ Integer i = 1
+ vfunc('foo', i)
+ }
+ }
+
+ assert new Foo().caller() == 'foo 1'
+ '''
+ }
+}