Github user blackdrag commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/546#discussion_r117645390
  
    --- Diff: 
src/test/org/codehaus/groovy/runtime/DefaultGroovyMethodsTest.groovy ---
    @@ -236,7 +236,28 @@ public class DefaultGroovyMethodsTest extends 
GroovyTestCase {
             assertEquals(3, list.get(2));
         }
     
    +    // GROOVY-7654
    +    public void testIterableAsList() {
    +        def list = [1, 2, 3]
    +        def iterable = new IterableWrapper(delegate: list)
    +
    +        def iterableAsList = iterable.asList()
    +        def iterableAsType = iterable as List
    +        
    +        assertEquals(iterableAsList, iterableAsType)
    +        assertEquals(1, iterableAsList[0])
    +        assertEquals(1, iterableAsType[0])
    +    }
    +
         private static class MyList extends ArrayList {
             public MyList() {}
         }
    +
    +    private static class IterableWrapper implements Iterable {
    +        Iterable delegate
    +
    +        Iterator iterator() {
    +            delegate.iterator()
    +        }
    +    }
     }
    --- End diff --
    
    If the iterable is an instance of Collection, then why isn´t the 
Collection taking method called directly?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to