class Test def main .test1 .test2 def test1 # Invoke a method in an extension of a generic, ancestor interface. # In this case, the class is Dictionary.KeyCollection # and the extension method is declared on IEnumerable which KeyCollection implements. # Then do it again for Dictionary.ValueCollection # Note that it implement IEnumerable which is using the *2nd* generic parameter, not the first. d = {'x': 1, 'y': 1} for key in d.keys.toList.sorted assert key in ['x', 'y'] assert (for key in d.keys.toList.sorted get key) == ['x', 'y'] for value in d.values.toList assert value == 1 assert (for value in d.values.toList get value) == [1, 1] def test2 x = X() .takeEnum(x) y = x.toList # previously broken. Cobra would not find the extension method. assert y == List(x) assert y == [1, 2, 3] def takeEnum(e as IEnumerable) assert e.toList is not e assert e.toList == List(e) class X implements IEnumerable def getEnumerator as IEnumerator return [1, 2, 3].getEnumerator def getEnumerator as System.Collections.IEnumerator implements System.Collections.IEnumerable return .getEnumerator