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 2022/03/12 22:07:44 UTC
[groovy] 02/02: GROOVY-10482: handle target type witness for parameterized static method
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 6d1902dadfc3b5f13cb2b0f42bcb700f8778f510
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Mar 12 15:56:18 2022 -0600
GROOVY-10482: handle target type witness for parameterized static method
---
.../transform/stc/StaticTypeCheckingVisitor.java | 6 +++---
.../groovy/transform/stc/GenericsSTCTest.groovy | 24 ++++++++++++----------
2 files changed, 16 insertions(+), 14 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 a17dc7e..08245b6 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -5388,9 +5388,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
actuals[i] = getType(a);
}
- // check for method call with known target
- if (!(a instanceof MethodCallExpression)) continue;
- if (((MethodCallExpression) a).isUsingGenerics()) continue;
+ // check for method call without type arguments, with a known target
+ if (!(a instanceof MethodCall) || (a instanceof MethodCallExpression
+ && ((MethodCallExpression) a).isUsingGenerics())) continue;
MethodNode aNode = a.getNodeMetaData(DIRECT_METHOD_CALL_TARGET);
if (aNode == null || aNode.getGenericsTypes() == null) continue;
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 5cc5b7c..2e91b70 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -2543,18 +2543,20 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
// GROOVY-10482
void testCompatibleArgumentsForPlaceholders6() {
- assertScript '''
- class Foo<X> {
- Foo(X x) {
+ ['', 'def', 'public', 'static', '@Deprecated'].each {
+ assertScript """
+ class Foo<X> {
+ Foo(X x) {
+ }
}
- }
- def <Y> Y bar() {
- }
- def <Z> void baz() {
- new Foo<Z>(bar()) // Cannot call Foo#<init>(Z) with arguments [#Y]
- }
- this.<String>baz()
- '''
+ $it <Y> Y bar() {
+ }
+ $it <Z> void baz() {
+ new Foo<Z>(bar()) // Cannot call Foo#<init>(Z) with arguments [#Y]
+ }
+ this.<String>baz()
+ """
+ }
}
void testIncompatibleArgumentsForPlaceholders1() {