[ https://issues.apache.org/jira/browse/GROOVY-7922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15500312#comment-15500312 ]
ASF GitHub Bot commented on GROOVY-7922: ---------------------------------------- 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<list.size();j++) { MethodNode two = list.get(j); if (toBeRemoved.contains(two)) continue; - if (one.getName().equals(two.getName()) && one.getDeclaringClass()==two.getDeclaringClass()) { - Parameter[] onePars = one.getParameters(); - Parameter[] twoPars = two.getParameters(); - if (onePars.length == twoPars.length) { - boolean sameTypes = true; - for (int k = 0; k < onePars.length; k++) { - Parameter onePar = onePars[k]; - Parameter twoPar = twoPars[k]; - if (!onePar.getType().equals(twoPar.getType())) { - sameTypes = false; - break; - } - } - if (sameTypes) { - 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); - } + Parameter[] onePars = one.getParameters(); + Parameter[] twoPars = two.getParameters(); + if (onePars.length == twoPars.length) { + if (areOverloadMethodsInSameClass(one,two)) { + if (ParameterUtils.parametersEqual(onePars, twoPars)){ --- End diff -- If the `Parameter[]` parameters are removed from `areEquivalentInterfaceMethods` method I think these arguments can be replaced with `one.getParameters(), two.getParameters()` and then the local variables wouldn't be needed. Just a suggestion. > Static type checking not strict enough in the presence of ambiguous method > matching > ----------------------------------------------------------------------------------- > > Key: GROOVY-7922 > URL: https://issues.apache.org/jira/browse/GROOVY-7922 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker > Reporter: Paul King > > This example: > {code} > import groovy.transform.CompileStatic > interface FooA {} > interface FooB {} > class FooAB implements FooA, FooB {} > @CompileStatic > class TestGroovy { > static void test() { println new TestGroovy().foo(new FooAB()) } > def foo(FooB x) { 43 } > def foo(FooA x) { 42 } > } > TestGroovy.test() > {code} > Should probably throw some kind of ambiguous method error during compilation > to match Java (and dynamic Groovy's runtime error). -- This message was sent by Atlassian JIRA (v6.3.4#6332)