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 2023/02/07 22:48:05 UTC

[groovy] branch GROOVY_2_5_X updated: GROOVY-8136: add test case

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

emilles pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
     new cb87a00802 GROOVY-8136: add test case
cb87a00802 is described below

commit cb87a0080230dfa21fc14c420eaf37aa6b5cdf76
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Feb 7 16:37:04 2023 -0600

    GROOVY-8136: add test case
---
 .../codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java | 2 +-
 src/test/groovy/transform/stc/ArraysAndCollectionsSTCTest.groovy | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

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 f537530389..54d895eb25 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -1431,7 +1431,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         }
         constructors = findMethod(node, "<init>", arguments);
         if (constructors.isEmpty()) {
-            if (isBeingCompiled(node) && !node.isInterface() && arguments.length == 1 && arguments[0].equals(LinkedHashMap_TYPE)) {
+            if (isBeingCompiled(node) && !node.isAbstract() && arguments.length == 1 && arguments[0].equals(LinkedHashMap_TYPE)) {
                 // there will be a default map constructor added later
                 Parameter[] params = {new Parameter(LinkedHashMap_TYPE, "args")};
                 return new ConstructorNode(Opcodes.ACC_PUBLIC, params, ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE);
diff --git a/src/test/groovy/transform/stc/ArraysAndCollectionsSTCTest.groovy b/src/test/groovy/transform/stc/ArraysAndCollectionsSTCTest.groovy
index 4bf8c427df..776ca2d5cb 100644
--- a/src/test/groovy/transform/stc/ArraysAndCollectionsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/ArraysAndCollectionsSTCTest.groovy
@@ -808,4 +808,13 @@ class ArraysAndCollectionsSTCTest extends StaticTypeCheckingTestCase {
         ''',
         'No matching constructor found'
     }
+
+    // GROOVY-8136
+    void testAbstractClassThatImplementsMapInitializedByMapLiteral() {
+        shouldFailWithMessages '''
+            abstract class MVM<K, V> implements Map<K, List<V>> { }
+            MVM map = [:] // no STC error; fails at runtime
+        ''',
+        'No matching constructor found'
+    }
 }