Version: 8.4.96.2033
Just found Extension for C# is available in 8.4 beta, and have a try to refactor my cross platform Iterable/Iterator with this awesome feature.
Here’s a problem with .NET/UWP:
public interface Iterator<T>
#if COOPER
: java.util.Iterator<T>
#elif ECHOES
: IEnumerator<T>
#endif
{
#if !COOPER
T next();
bool hasNext();
#endif
}
public __extension class IteratorDefault<T> : Iterator<T>{
#if COOPER
public void remove() {}
#elif ECHOES
// (E170) "implements" type "IEnumerator" is not in the inheritance list of this type
public object IEnumerator.Current => next();
public T Current => next();
public bool MoveNext() => hasNext();
public void Reset() {}
public void Dispose() {}
#endif
}
// (E181) Property "Current: Object" getter not implemented as required for interface "IEnumerator"
public class TestIterator : Iterator<string>{
public string next() => null;
public bool hasNext() => false;
}
The Extension is indeed able to add default implementation for interface, but it seems can’t recognize inheritance with ambiguity. Is there a way to fix that?