You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by sh...@apache.org on 2016/06/04 03:36:39 UTC
groovy git commit: GROOVY-7849: Verifier should be aware of array
type covariance when checking overriding method return types (closes #346)
Repository: groovy
Updated Branches:
refs/heads/master 38439af66 -> 7c25c4197
GROOVY-7849: Verifier should be aware of array type covariance when checking overriding method return types (closes #346)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7c25c419
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7c25c419
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7c25c419
Branch: refs/heads/master
Commit: 7c25c4197738c73bb87003c568786d7d1eea99fb
Parents: 38439af
Author: Shil Sinha <sh...@gmail.com>
Authored: Thu Jun 2 13:54:13 2016 -0400
Committer: Shil Sinha <sh...@apache.org>
Committed: Fri Jun 3 23:07:21 2016 -0400
----------------------------------------------------------------------
.../org/codehaus/groovy/classgen/Verifier.java | 2 +-
src/test/groovy/OverrideTest.groovy | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/7c25c419/src/main/org/codehaus/groovy/classgen/Verifier.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/Verifier.java b/src/main/org/codehaus/groovy/classgen/Verifier.java
index e907d96..c950e51 100644
--- a/src/main/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/org/codehaus/groovy/classgen/Verifier.java
@@ -1395,7 +1395,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
private boolean isArrayAssignable(ClassNode node, ClassNode testNode) {
if (node.isArray() && testNode.isArray()) { return isArrayAssignable(node.getComponentType(), testNode.getComponentType()); }
- return node.equals(testNode);
+ return isAssignable(node, testNode);
}
private static Parameter[] cleanParameters(Parameter[] parameters) {
http://git-wip-us.apache.org/repos/asf/groovy/blob/7c25c419/src/test/groovy/OverrideTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/OverrideTest.groovy b/src/test/groovy/OverrideTest.groovy
index 78ff192..cf620ed 100644
--- a/src/test/groovy/OverrideTest.groovy
+++ b/src/test/groovy/OverrideTest.groovy
@@ -174,4 +174,22 @@ def d = new Derived()
new TemplatedInterfaceImplementation()
'''
}
+
+ //GROOVY-7849
+ void testArrayReturnTypeCovariance() {
+ assertScript '''
+ interface Base {}
+
+ interface Derived extends Base {}
+
+ interface I {
+ Base[] foo()
+ }
+
+ class C implements I {
+ Derived[] foo() { null }
+ }
+ new C().foo()
+ '''
+ }
}