[1/2] groovy git commit: Revert "GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599)"

2017-09-13 Thread sunlan
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 6e47e6df4 -> ddebbeca2


Revert "GROOVY-7721: Static type checking fails when compiling against a Java 
interface call (closes #599)"

This reverts commit 34df6cf461a5ecce66f2c2c0f14489cf96feaf34.

(cherry picked from commit 695b7af)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 22635dac48a84152fecc887e5a919efdd52009be
Parents: 6e47e6d
Author: sunlan 
Authored: Wed Sep 13 22:35:50 2017 +0800
Committer: sunlan 
Committed: Wed Sep 13 22:47:48 2017 +0800

--
 .../stc/StaticTypeCheckingSupport.java  | 11 +--
 src/test/groovy/bugs/Groovy7721Bug.groovy   | 80 
 2 files changed, 2 insertions(+), 89 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/22635dac/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
--
diff --git 
a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java 
b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index eb208fe..98fb157 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1149,20 +1149,13 @@ public abstract class StaticTypeCheckingSupport {
 private static void removeMethodWithSuperReturnType(List 
toBeRemoved, MethodNode one, MethodNode two) {
 ClassNode oneRT = one.getReturnType();
 ClassNode twoRT = two.getReturnType();
-if (isCovariant(oneRT, twoRT)) {
+if (oneRT.isDerivedFrom(twoRT) || oneRT.implementsInterface(twoRT)) {
 toBeRemoved.add(two);
-} else if (isCovariant(twoRT, oneRT)) {
+} else if (twoRT.isDerivedFrom(oneRT) || 
twoRT.implementsInterface(oneRT)) {
 toBeRemoved.add(one);
 }
 }
 
-private static boolean isCovariant(ClassNode left, ClassNode right) {
-if (left.isArray() && right.isArray()) {
-return isCovariant(left.getComponentType(), 
right.getComponentType());
-}
-return left.isDerivedFrom(right) || left.implementsInterface(right);
-}
-
 private static boolean areOverloadMethodsInSameClass(MethodNode one, 
MethodNode two) {
 return one.getName().equals(two.getName()) && one.getDeclaringClass() 
== two.getDeclaringClass();
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/22635dac/src/test/groovy/bugs/Groovy7721Bug.groovy
--
diff --git a/src/test/groovy/bugs/Groovy7721Bug.groovy 
b/src/test/groovy/bugs/Groovy7721Bug.groovy
deleted file mode 100644
index f316a2a..000
--- a/src/test/groovy/bugs/Groovy7721Bug.groovy
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-
-package groovy.bugs
-
-import org.codehaus.groovy.control.CompilerConfiguration
-import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit
-
-class Groovy7721Bug extends GroovyTestCase {
-void testCovariantArrayAtOverriding() {
-def config = new CompilerConfiguration()
-config.with {
-targetDirectory = createTempDir()
-jointCompilationOptions = [stubDir: createTempDir()]
-}
-
-File parentDir = createTempDir()
-try {
-def a = new File(parentDir, 'A.java')
-a.write '''
-package pack;
-interface A {
-Object[] bar();
-}
-
-'''
-def b = new File(parentDir, 'B.java')
-b.write '''
-package pack;
-interface B extends A {
- 

groovy git commit: Revert "GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599)"

2017-09-13 Thread sunlan
Repository: groovy
Updated Branches:
  refs/heads/master a4f779335 -> 695b7afb7


Revert "GROOVY-7721: Static type checking fails when compiling against a Java 
interface call (closes #599)"

This reverts commit 34df6cf461a5ecce66f2c2c0f14489cf96feaf34.


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

Branch: refs/heads/master
Commit: 695b7afb7b2652b0e2043189b8c0b3c97f97c2c4
Parents: a4f7793
Author: sunlan 
Authored: Wed Sep 13 22:35:50 2017 +0800
Committer: sunlan 
Committed: Wed Sep 13 22:35:50 2017 +0800

--
 .../stc/StaticTypeCheckingSupport.java  | 11 +--
 src/test/groovy/bugs/Groovy7721Bug.groovy   | 80 
 2 files changed, 2 insertions(+), 89 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/695b7afb/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
--
diff --git 
a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java 
b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index eb208fe..98fb157 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1149,20 +1149,13 @@ public abstract class StaticTypeCheckingSupport {
 private static void removeMethodWithSuperReturnType(List 
toBeRemoved, MethodNode one, MethodNode two) {
 ClassNode oneRT = one.getReturnType();
 ClassNode twoRT = two.getReturnType();
-if (isCovariant(oneRT, twoRT)) {
+if (oneRT.isDerivedFrom(twoRT) || oneRT.implementsInterface(twoRT)) {
 toBeRemoved.add(two);
-} else if (isCovariant(twoRT, oneRT)) {
+} else if (twoRT.isDerivedFrom(oneRT) || 
twoRT.implementsInterface(oneRT)) {
 toBeRemoved.add(one);
 }
 }
 
-private static boolean isCovariant(ClassNode left, ClassNode right) {
-if (left.isArray() && right.isArray()) {
-return isCovariant(left.getComponentType(), 
right.getComponentType());
-}
-return left.isDerivedFrom(right) || left.implementsInterface(right);
-}
-
 private static boolean areOverloadMethodsInSameClass(MethodNode one, 
MethodNode two) {
 return one.getName().equals(two.getName()) && one.getDeclaringClass() 
== two.getDeclaringClass();
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/695b7afb/src/test/groovy/bugs/Groovy7721Bug.groovy
--
diff --git a/src/test/groovy/bugs/Groovy7721Bug.groovy 
b/src/test/groovy/bugs/Groovy7721Bug.groovy
deleted file mode 100644
index f316a2a..000
--- a/src/test/groovy/bugs/Groovy7721Bug.groovy
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-
-package groovy.bugs
-
-import org.codehaus.groovy.control.CompilerConfiguration
-import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit
-
-class Groovy7721Bug extends GroovyTestCase {
-void testCovariantArrayAtOverriding() {
-def config = new CompilerConfiguration()
-config.with {
-targetDirectory = createTempDir()
-jointCompilationOptions = [stubDir: createTempDir()]
-}
-
-File parentDir = createTempDir()
-try {
-def a = new File(parentDir, 'A.java')
-a.write '''
-package pack;
-interface A {
-Object[] bar();
-}
-
-'''
-def b = new File(parentDir, 'B.java')
-b.write '''
-package pack;
-interface B extends A {
-@Override
-String[]