Could someone help me understand the rules for DGMs when multiple methods apply?  I can't seem to find anything in the specification that addresses this and I need to emulate (or call into) the rules for Eclipse.  I also tried walking through MetaClassImpl and MetaMethodIndex, but I got lost in the cache loading code.

 

DefaultGroovyMethods defines these two methods, in this order.  At runtime, if I have an ArrayList, sort(Iterable,Closure) is the method that is called.  Is this because 1) Iterable has wider applicability than Collection, 2) the Collection version is deprecated, 3) the Iterable version is defined last, or 4) something else?

 

    @Deprecated

    public static <T> List<T> sort(Collection<T> self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {

        ...

    }

 

    public static <T> List<T> sort(  Iterable<T> self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {

        ...

    }

 

Eric Milles
Lead Software Engineer

Thomson Reuters

Email: eric.milles@thomsonreuters.com

Phone: 651-848-7040