formatting
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5b06149b Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5b06149b Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5b06149b Branch: refs/heads/master Commit: 5b06149b93585545e391acb68920fea2341619b0 Parents: 2da308c Author: John Wagenleitner <jwagenleit...@apache.org> Authored: Sun Sep 18 10:56:55 2016 -0700 Committer: John Wagenleitner <jwagenleit...@apache.org> Committed: Mon Sep 19 20:22:48 2016 -0700 ---------------------------------------------------------------------- .../stc/StaticTypeCheckingSupport.java | 22 ++++++++++---------- src/test/groovy/bugs/Groovy7922Bug.groovy | 19 +++++++++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/5b06149b/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 10f5e01..e2d5d29 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -1108,18 +1108,18 @@ public abstract class StaticTypeCheckingSupport { } private static Collection<MethodNode> removeCovariantsAndInterfaceEquivalents(Collection<MethodNode> collection) { - if (collection.size()<=1) return collection; + if (collection.size() <= 1) return collection; List<MethodNode> toBeRemoved = new LinkedList<MethodNode>(); List<MethodNode> list = new LinkedList<MethodNode>(new HashSet<MethodNode>(collection)); - for (int i=0;i<list.size()-1;i++) { + for (int i = 0; i < list.size() - 1; i++) { MethodNode one = list.get(i); if (toBeRemoved.contains(one)) continue; - for (int j=i+1;j<list.size();j++) { + for (int j = i + 1; j < list.size(); j++) { MethodNode two = list.get(j); if (toBeRemoved.contains(two)) continue; if (one.getParameters().length == two.getParameters().length) { if (areOverloadMethodsInSameClass(one,two)) { - if (ParameterUtils.parametersEqual(one.getParameters(), two.getParameters())){ + if (ParameterUtils.parametersEqual(one.getParameters(), two.getParameters())) { removeMethodWithSuperReturnType(toBeRemoved, one, two); } else { // this is an imperfect solution to determining if two methods are @@ -1127,7 +1127,7 @@ public abstract class StaticTypeCheckingSupport { // in that case, Java marks the Object version as synthetic removeSyntheticMethodIfOne(toBeRemoved, one, two); } - }else if(areEquivalentInterfaceMethods(one, two)){ + } else if (areEquivalentInterfaceMethods(one, two)) { // GROOVY-6970 choose between equivalent interface methods removeMethodInSuperInterface(toBeRemoved, one, two); } @@ -1141,11 +1141,11 @@ public abstract class StaticTypeCheckingSupport { } private static void removeMethodInSuperInterface(List<MethodNode> toBeRemoved, MethodNode one, MethodNode two) { - ClassNode oneDC=one.getDeclaringClass(); - ClassNode twoDC=two.getDeclaringClass(); - if(oneDC.implementsInterface(twoDC)){ + ClassNode oneDC = one.getDeclaringClass(); + ClassNode twoDC = two.getDeclaringClass(); + if (oneDC.implementsInterface(twoDC)) { toBeRemoved.add(two); - }else{ + } else { toBeRemoved.add(one); } } @@ -1175,8 +1175,8 @@ public abstract class StaticTypeCheckingSupport { } } - private static boolean areOverloadMethodsInSameClass(MethodNode one, MethodNode two){ - return one.getName().equals(two.getName()) && one.getDeclaringClass()==two.getDeclaringClass(); + 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/5b06149b/src/test/groovy/bugs/Groovy7922Bug.groovy ---------------------------------------------------------------------- diff --git a/src/test/groovy/bugs/Groovy7922Bug.groovy b/src/test/groovy/bugs/Groovy7922Bug.groovy index c71d774..57ee8de 100644 --- a/src/test/groovy/bugs/Groovy7922Bug.groovy +++ b/src/test/groovy/bugs/Groovy7922Bug.groovy @@ -1,3 +1,22 @@ +/* + * 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 gls.CompilableTestSupport;