groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kee...@apache.org
Subject incubator-groovy git commit: GROOVY-7520: Improve unimplemented message for abstract methods (closes #78)
Date Thu, 30 Jul 2015 22:34:15 GMT
Repository: incubator-groovy
Updated Branches:
  refs/heads/master c3a802fe1 -> 971cee027


GROOVY-7520: Improve unimplemented message for abstract methods (closes #78)


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/971cee02
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/971cee02
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/971cee02

Branch: refs/heads/master
Commit: 971cee027b34b9e5d92ed6c8cce3c541af0974f6
Parents: c3a802f
Author: Keegan Witt <keeganwitt@gmail.com>
Authored: Thu Jul 23 12:04:54 2015 -0400
Committer: Keegan Witt <keeganwitt@gmail.com>
Committed: Thu Jul 30 17:56:28 2015 -0400

----------------------------------------------------------------------
 .../groovy/classgen/ClassCompletionVerifier.java   |  2 +-
 src/test/groovy/bugs/Groovy7520Bug.groovy          | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/971cee02/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java b/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
index 6364811..6ca12e6 100644
--- a/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
+++ b/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
@@ -133,7 +133,7 @@ public class ClassCompletionVerifier extends ClassCodeVisitorSupport {
         if (abstractMethods == null) return;
         for (MethodNode method : abstractMethods) {
             MethodNode sameArgsMethod = node.getMethod(method.getName(), method.getParameters());
-            if (sameArgsMethod==null) {
+            if (sameArgsMethod==null || method.getReturnType().equals(sameArgsMethod.getReturnType()))
{
                 addError("Can't have an abstract method in a non-abstract class." +
                         " The " + getDescription(node) + " must be declared abstract or"
+
                         " the " + getDescription(method) + " must be implemented.", node);

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/971cee02/src/test/groovy/bugs/Groovy7520Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy7520Bug.groovy b/src/test/groovy/bugs/Groovy7520Bug.groovy
new file mode 100644
index 0000000..1f07c20
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy7520Bug.groovy
@@ -0,0 +1,17 @@
+package groovy.bugs
+
+class Groovy7520Bug extends GroovyTestCase {
+    void testShouldSeeConflictUsingAbstractMethod() {
+        def msg = shouldFail '''
+            abstract class DefinesMethod {
+                abstract String getName()
+            }
+            class Foo extends DefinesMethod {
+                static int name = 666
+            }
+            new Foo().name
+            '''
+
+        assert msg.contains("Abstract method 'java.lang.String getName()' is not implemented
but a method of the same name but different return type is defined: static method 'int getName()'")
+    }
+}


Mime
View raw message