From 82f5d45956d4eae4931ad8d2037ec2f290a08686 Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Sun, 1 May 2022 09:53:55 -0500 Subject: [PATCH] GROOVY-10267, GROOVY-10576 --- .../core/tests/xform/TypeCheckedTests.java | 20 +++++++++++++++++++ .../org/codehaus/groovy/ast/GenericsType.java | 4 ++-- .../org/codehaus/groovy/ast/GenericsType.java | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java index e9eea4288a..957c4aa6be 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java @@ -4576,6 +4576,26 @@ public void testTypeChecked10254() { runConformTest(sources, "42"); } + @Test + public void testTypeChecked10267() { + //@formatter:off + String[] sources = { + "Main.groovy", + "class C {\n" + + "}\n" + + "@groovy.transform.TypeChecked\n" + + "C test() {\n" + + " test2()\n" + + "}\n" + + "C test2() {\n" + + "}\n" + + "test()\n", + }; + //@formatter:on + + runConformTest(sources); + } + @Test public void testTypeChecked10269() { assumeTrue(isParrotParser()); diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java index 6cb1186c54..f4ec17a5de 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java @@ -487,8 +487,8 @@ private boolean compareGenericsWithBound(final ClassNode classNode, final ClassN match = gt.new GenericsTypeMatcher().checkGenerics(classNodeType.getLowerBound()); } else if (classNodeType.getUpperBounds() != null) { match = gt.new GenericsTypeMatcher().checkGenerics(classNodeType.getUpperBounds()[0]); - } else { - match = false; // "?" (from Comparable) does not satisfy anything + } else { // GROOVY-10267, GROOVY-10576: "?" vs "? extends Object" (citation required) or no match + match = (!gt.isPlaceholder() && !gt.isWildcard() && ClassHelper.OBJECT_TYPE.equals(gt.getType())); } } else { match = implementsInterfaceOrIsSubclassOf(classNodeType.getType(), gt.getType()); diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/GenericsType.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/GenericsType.java index 8661b879b3..977b545a96 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/GenericsType.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/GenericsType.java @@ -470,8 +470,8 @@ private static boolean compareGenericsWithBound(final ClassNode classNode, final match = gt.checkGenerics(classNodeType.getLowerBound()); } else if (classNodeType.getUpperBounds() != null) { match = gt.checkGenerics(classNodeType.getUpperBounds()[0]); - } else { - match = false; // "?" (from Comparable) does not satisfy anything + } else { // GROOVY-10267, GROOVY-10576: "?" vs "? extends Object" (citation required) or no match + match = (!gt.isPlaceholder() && !gt.isWildcard() && ClassHelper.OBJECT_TYPE.equals(gt.getType())); } } else { match = implementsInterfaceOrIsSubclassOf(classNodeType.getType(), gt.getType());