Wondering how to do this in Cobra...
- Code: Select all
class ReadOnlyList<T> : IEnumerable, IEnumerable<T>
{
/* Stuff */
IEnumerator IEnumerable.GetEnumerator()
{
return _list.GetEnumerator();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return _list.GetEnumerator();
}
}
If I just specify the methods...
- Code: Select all
class ReadOnlyList<of T> implements IEnumerable, IEnumerable<of T>
# Stuff
def getEnumerator as IEnumerator?
return _list.getEnumerator
def getEnumerator as IEnumerator<of T>?
return _list.getEnumerator # line 48
ReadOnlyList.cobra(48): error: Cannot return IEnumerator? because "getEnumerator" is declared to return a IEnumerator<of T>?.
It's calling the non-generic one in both cases thought though _list is IList<of T>, and so complains in the second case.
If I only define the first one then it compiles, so that part is a bug, in that it should say that the class didn't define getEnumerator from Enumerator<T>. I discovered this because using the assembly from C# blows up gmcs.
I'll raise a ticket on the second issue, but first I just wanted to ask if this disambiguation is implemented or if there's a workaround in the meantime.
Thanks!
PS: If it's not implemented yet this is the syntax that seemed natural to me when I was trying various things to see what might work...
- Code: Select all
def getEnumerator from IEnumerable as IEnumerator?
return _list.getEnumerator
def getEnumerator from IEnumerable<of T> as IEnumerator<of T>?
return _list.getEnumerator