Skip to content

Commit 23162ac

Browse files
committed
GROOVY-8136
1 parent eef468a commit 23162ac

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,29 @@ public void testTypeChecked8136() {
19281928
"----------\n");
19291929
}
19301930

1931+
@Test
1932+
public void testTypeChecked8136a() {
1933+
//@formatter:off
1934+
String[] sources = {
1935+
"Main.groovy",
1936+
"abstract class MVM<K,V> implements Map<K,List<V>> {}\n" +
1937+
"@groovy.transform.TypeChecked\n" +
1938+
"@SuppressWarnings('rawtypes')\n" +
1939+
"void test() {\n" +
1940+
" MVM m = [:]\n" +
1941+
"}\n",
1942+
};
1943+
//@formatter:on
1944+
1945+
runNegativeTest(sources,
1946+
"----------\n" +
1947+
"1. ERROR in Main.groovy (at line 5)\n" +
1948+
"\tMVM m = [:]\n" +
1949+
"\t ^^^\n" +
1950+
"Groovy:[Static type checking] - Cannot find matching constructor MVM(java.util.LinkedHashMap)\n" +
1951+
"----------\n");
1952+
}
1953+
19311954
@Test
19321955
public void testTypeChecked8202() {
19331956
//@formatter:off

base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ protected MethodNode checkGroovyStyleConstructor(final ClassNode node, final Cla
15791579
}
15801580
constructors = findMethod(node, "<init>", arguments);
15811581
if (constructors.isEmpty()) {
1582-
if (isBeingCompiled(node) && !node.isInterface() && arguments.length == 1 && arguments[0].equals(LINKEDHASHMAP_CLASSNODE)) {
1582+
if (isBeingCompiled(node) && !node.isAbstract() && arguments.length == 1 && arguments[0].equals(LINKEDHASHMAP_CLASSNODE)) {
15831583
// there will be a default hash map constructor added later
15841584
ConstructorNode cn = new ConstructorNode(Opcodes.ACC_PUBLIC, new Parameter[]{
15851585
new Parameter(LINKEDHASHMAP_CLASSNODE, "args")

base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ protected MethodNode checkGroovyStyleConstructor(final ClassNode node, final Cla
15141514
}
15151515
constructors = findMethod(node, "<init>", arguments);
15161516
if (constructors.isEmpty()) {
1517-
if (isBeingCompiled(node) && !node.isInterface() && arguments.length == 1 && arguments[0].equals(LinkedHashMap_TYPE)) {
1517+
if (isBeingCompiled(node) && !node.isAbstract() && arguments.length == 1 && arguments[0].equals(LinkedHashMap_TYPE)) {
15181518
// there will be a default hash map constructor added later
15191519
return new ConstructorNode(Opcodes.ACC_PUBLIC, new Parameter[]{new Parameter(LinkedHashMap_TYPE, "args")}, ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE);
15201520
} else {

base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ protected MethodNode checkGroovyStyleConstructor(final ClassNode node, final Cla
14031403
}
14041404
constructors = findMethod(node, "<init>", arguments);
14051405
if (constructors.isEmpty()) {
1406-
if (isBeingCompiled(node) && !node.isInterface() && arguments.length == 1 && arguments[0].equals(LinkedHashMap_TYPE)) {
1406+
if (isBeingCompiled(node) && !node.isAbstract() && arguments.length == 1 && arguments[0].equals(LinkedHashMap_TYPE)) {
14071407
// there will be a default hash map constructor added later
14081408
return new ConstructorNode(Opcodes.ACC_PUBLIC, new Parameter[]{new Parameter(LinkedHashMap_TYPE, "args")}, ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE);
14091409
} else {

0 commit comments

Comments
 (0)