[GitHub] groovy pull request #422: GROOVY-7922: Static type checking not strict enoug...

2016-09-19 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/groovy/pull/422


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #422: GROOVY-7922: Static type checking not strict enoug...

2016-09-18 Thread blindpirate
Github user blindpirate commented on a diff in the pull request:

https://github.com/apache/groovy/pull/422#discussion_r79298948
  
--- Diff: 
src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java ---
@@ -1157,6 +1142,45 @@ private static ClassNode makeRawType(final ClassNode 
receiver) {
 return result;
 }
 
+private static void removeMethodInSuperInterface(List 
toBeRemoved, MethodNode one, MethodNode two) {
+ClassNode oneDC=one.getDeclaringClass();
+ClassNode twoDC=two.getDeclaringClass();
+if(oneDC.implementsInterface(twoDC)){
+toBeRemoved.add(two);
+}else{
+toBeRemoved.add(one);
+}
+}
+
+private static boolean areEquivalentInterfaceMethods(MethodNode one, 
MethodNode two, Parameter[] onePars, Parameter[] twoPars) {
--- End diff --

Yes, good suggestion. I will do that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #422: GROOVY-7922: Static type checking not strict enoug...

2016-09-17 Thread jwagenleitner
Github user jwagenleitner commented on a diff in the pull request:

https://github.com/apache/groovy/pull/422#discussion_r79297750
  
--- Diff: 
src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java ---
@@ -1157,6 +1142,45 @@ private static ClassNode makeRawType(final ClassNode 
receiver) {
 return result;
 }
 
+private static void removeMethodInSuperInterface(List 
toBeRemoved, MethodNode one, MethodNode two) {
+ClassNode oneDC=one.getDeclaringClass();
+ClassNode twoDC=two.getDeclaringClass();
+if(oneDC.implementsInterface(twoDC)){
+toBeRemoved.add(two);
+}else{
+toBeRemoved.add(one);
+}
+}
+
+private static boolean areEquivalentInterfaceMethods(MethodNode one, 
MethodNode two, Parameter[] onePars, Parameter[] twoPars) {
--- End diff --

I think it would simplify things if this just took 2 MethodNode's, the 
parameters can be gotten from the nodes so no need to pass them in I think?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #422: GROOVY-7922: Static type checking not strict enoug...

2016-09-17 Thread jwagenleitner
Github user jwagenleitner commented on a diff in the pull request:

https://github.com/apache/groovy/pull/422#discussion_r79297788
  
--- Diff: 
src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java ---
@@ -1116,39 +1117,23 @@ private static ClassNode makeRawType(final 
ClassNode receiver) {
 for (int j=i+1;j

[GitHub] groovy pull request #422: GROOVY-7922: Static type checking not strict enoug...

2016-09-16 Thread blindpirate
Github user blindpirate commented on a diff in the pull request:

https://github.com/apache/groovy/pull/422#discussion_r79272298
  
--- Diff: 
src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java ---
@@ -1157,6 +1141,56 @@ private static ClassNode makeRawType(final ClassNode 
receiver) {
 return result;
 }
 
+private static void removeMethodInSuperInterface(List 
toBeRemoved, MethodNode one, MethodNode two) {
+ClassNode oneDC=one.getDeclaringClass();
+ClassNode twoDC=two.getDeclaringClass();
+if(oneDC.implementsInterface(twoDC)){
+toBeRemoved.add(two);
+}else{
+toBeRemoved.add(one);
+}
+}
+
+private static boolean areEquivalentInterfaceMethods(MethodNode one, 
MethodNode two, Parameter[] onePars, Parameter[] twoPars) {
+return one.getName().equals(two.getName())
+&& one.getDeclaringClass().isInterface()
+&& two.getDeclaringClass().isInterface()
+&& allParameterTypesAreSame(onePars, twoPars);
+}
+
+private static void removeSyntheticMethodIfOne(List 
toBeRemoved, MethodNode one, MethodNode two) {
+if (one.isSynthetic() && !two.isSynthetic()) {
+toBeRemoved.add(one);
+} else if (two.isSynthetic() && !one.isSynthetic()) {
+toBeRemoved.add(two);
+}
+}
+
+private static void removeMethodWithSuperReturnType(List 
toBeRemoved, MethodNode one, MethodNode two) {
+ClassNode oneRT = one.getReturnType();
+ClassNode twoRT = two.getReturnType();
+if (oneRT.isDerivedFrom(twoRT) || 
oneRT.implementsInterface(twoRT)) {
+toBeRemoved.add(two);
+} else if (twoRT.isDerivedFrom(oneRT) || 
twoRT.implementsInterface(oneRT)) {
+toBeRemoved.add(one);
+}
+}
+
+private static boolean areOverloadMethodsInSameClass(MethodNode one, 
MethodNode two){
+return one.getName().equals(two.getName()) && 
one.getDeclaringClass()==two.getDeclaringClass();
+}
+
+private static boolean allParameterTypesAreSame(Parameter[] onePars, 
Parameter[] twoPars) {
--- End diff --

Oh, you're right. I will use this method instead.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #422: GROOVY-7922: Static type checking not strict enoug...

2016-09-16 Thread blindpirate
GitHub user blindpirate opened a pull request:

https://github.com/apache/groovy/pull/422

GROOVY-7922: Static type checking not strict enough in the presence o…

…f ambiguous method matching


the issue has been resolved and some refactor are done

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/blindpirate/groovy groovy7922bug

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/groovy/pull/422.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #422


commit b2d84738986fc83a589e78ec205bb206318a1e4a
Author: zhangbo 
Date:   2016-09-16T00:29:11Z

GROOVY-7922: Static type checking not strict enough in the presence of 
ambiguous method matching




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---