You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2024/06/20 19:03:34 UTC

(groovy) branch master updated: STC: method match error for primitive receiver

This is an automated email from the ASF dual-hosted git repository.

emilles 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 defefcb998 STC: method match error for primitive receiver
defefcb998 is described below

commit defefcb998b86e838388185643cd5c97f2e1973f
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Jun 20 14:01:15 2024 -0500

    STC: method match error for primitive receiver
---
 .../groovy/transform/stc/StaticTypeCheckingVisitor.java      |  2 +-
 src/test/groovy/transform/stc/BugsSTCTest.groovy             | 12 ++++++------
 src/test/groovy/transform/stc/STCAssignmentTest.groovy       |  4 ++--
 src/test/groovy/transform/stc/STCnAryExpressionTest.groovy   |  2 +-
 .../groovy/transform/stc/TypeCheckingExtensionsTest.groovy   |  4 ++--
 src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy    |  2 +-
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 27a9b0b3d7..f3b93de708 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -5928,7 +5928,7 @@ trying: for (ClassNode[] signature : signatures) {
             if (receiver.isEnum() && args.length >= 2) args = Arrays.copyOfRange(args, 2, args.length);
             error = "Cannot find matching constructor " + prettyPrintTypeName(receiver) + toMethodParametersString("", args);
         } else {
-            ClassNode type = isClassClassNodeWrappingConcreteType(receiver) ? receiver.getGenericsTypes()[0].getType() : receiver;
+            ClassNode type = isClassClassNodeWrappingConcreteType(receiver) ? receiver.getGenericsTypes()[0].getType() : wrapTypeIfNecessary(receiver);
             error = "Cannot find matching method " + prettyPrintTypeName(type) + "#" + toMethodParametersString(name, args) + ". Please check if the declared type is correct and if the method exists.";
         }
         addStaticTypeError(error, origin);
diff --git a/src/test/groovy/transform/stc/BugsSTCTest.groovy b/src/test/groovy/transform/stc/BugsSTCTest.groovy
index 22108a6f89..6d24223915 100644
--- a/src/test/groovy/transform/stc/BugsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/BugsSTCTest.groovy
@@ -38,7 +38,7 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
             def foo(Closure cls) {}
             def bar() { foo { 2 / it } }
         ''',
-        'Cannot find matching method int#div(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#div(java.lang.Object)'
     }
     void testShouldNotAllowModOnUntypedVariable() {
         shouldFailWithMessages '''
@@ -52,7 +52,7 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
             def foo(Closure cls) {}
             def bar() { foo { 2.mod(it) } }
         ''',
-        'Cannot find matching method int#mod(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#mod(java.lang.Object)'
     }
     void testShouldNotAllowRemainderOnUntypedVariable() {
         shouldFailWithMessages '''
@@ -66,7 +66,7 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
             def foo(Closure cls) {}
             def bar() { foo { 2 % it } }
         ''',
-        'Cannot find matching method int#remainder(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#remainder(java.lang.Object)'
     }
     void testShouldNotAllowMulOnUntypedVariable() {
         shouldFailWithMessages '''
@@ -80,7 +80,7 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
             def foo(Closure cls) {}
             def bar() { foo { 2 * it } }
         ''',
-        'Cannot find matching method int#multiply(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#multiply(java.lang.Object)'
     }
     void testShouldNotAllowPlusOnUntypedVariable() {
         shouldFailWithMessages '''
@@ -94,7 +94,7 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
             def foo(Closure cls) {}
             def bar() { foo { 2 + it } }
         ''',
-        'Cannot find matching method int#plus(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#plus(java.lang.Object)'
     }
     void testShouldNotAllowMinusOnUntypedVariable() {
         shouldFailWithMessages '''
@@ -108,7 +108,7 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
             def foo(Closure cls) {}
             def bar() { foo { 2 - it } }
         ''',
-        'Cannot find matching method int#minus(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#minus(java.lang.Object)'
     }
 
     // GROOVY-7929
diff --git a/src/test/groovy/transform/stc/STCAssignmentTest.groovy b/src/test/groovy/transform/stc/STCAssignmentTest.groovy
index 1f0a78f0ce..9aeabcfa4a 100644
--- a/src/test/groovy/transform/stc/STCAssignmentTest.groovy
+++ b/src/test/groovy/transform/stc/STCAssignmentTest.groovy
@@ -158,7 +158,7 @@ class STCAssignmentTest extends StaticTypeCheckingTestCase {
             int i = 0
             i += new Object()
         ''',
-        'Cannot find matching method int#plus(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#plus(java.lang.Object)'
     }
 
     void testIntMinusEqualsObject() {
@@ -166,7 +166,7 @@ class STCAssignmentTest extends StaticTypeCheckingTestCase {
             int i = 0
             i -= new Object()
         ''',
-        'Cannot find matching method int#minus(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#minus(java.lang.Object)'
     }
 
     void testStringPlusEqualsString() {
diff --git a/src/test/groovy/transform/stc/STCnAryExpressionTest.groovy b/src/test/groovy/transform/stc/STCnAryExpressionTest.groovy
index 67f4b06fcb..c7d40be540 100644
--- a/src/test/groovy/transform/stc/STCnAryExpressionTest.groovy
+++ b/src/test/groovy/transform/stc/STCnAryExpressionTest.groovy
@@ -54,7 +54,7 @@ class STCnAryExpressionTest extends StaticTypeCheckingTestCase {
             int num = 2
             num+obj
         ''',
-        'Cannot find matching method int#plus(java.lang.Object)'
+        'Cannot find matching method java.lang.Integer#plus(java.lang.Object)'
     }
 
     // GROOVY-10818
diff --git a/src/test/groovy/transform/stc/TypeCheckingExtensionsTest.groovy b/src/test/groovy/transform/stc/TypeCheckingExtensionsTest.groovy
index 78088f62e2..7e4c3294e9 100644
--- a/src/test/groovy/transform/stc/TypeCheckingExtensionsTest.groovy
+++ b/src/test/groovy/transform/stc/TypeCheckingExtensionsTest.groovy
@@ -330,7 +330,7 @@ class TypeCheckingExtensionsTest extends StaticTypeCheckingTestCase {
             Date y = new Date()
             x+y
         ''',
-        'Cannot find matching method int#plus(java.util.Date)'
+        'Cannot find matching method java.lang.Integer#plus(java.util.Date)'
 
         extension = 'groovy/transform/stc/BinaryOperatorTestExtension.groovy'
         assertScript '''
@@ -349,7 +349,7 @@ class TypeCheckingExtensionsTest extends StaticTypeCheckingTestCase {
             Date y = new Date()
             x << y
         ''',
-        'Cannot find matching method int#leftShift(java.util.Date)'
+        'Cannot find matching method java.lang.Integer#leftShift(java.util.Date)'
 
         extension = 'groovy/transform/stc/BinaryOperatorTestExtension.groovy'
         assertScript '''
diff --git a/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy
index 2d57ff3427..5d395506d9 100644
--- a/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy
@@ -910,7 +910,7 @@ class TypeInferenceSTCTest extends StaticTypeCheckingTestCase {
                 method().toUpperCase()
             }
         ''',
-        'Cannot find matching method int#toUpperCase()'
+        'Cannot find matching method java.lang.Integer#toUpperCase()'
    }
 
     void testDeclarationTypeInference() {