https://issues.dlang.org/show_bug.cgi?id=3075
--- Comment #31 from Bolpat <[email protected]> --- In the context of Argument-dependent Attributes (ADA) or Attributes for Higher-Order Functions (AfHOF) (pending DIPs), contravariant overloading is necessary. Imagine a proper sink-toString interface. The whole reason to have a sink in the first place instead of returning an allocated string is not doing the allocation. So, considering interface SinkToString { void toString(scope void delegate(char) @nogc) @nogc; } the following override should work in some way: class C : SinkToString { override(scope void delegate(char) @nogc) void toString(in void delegate(char) sink) @nogc const { ... } } The intention of the interface is: toString is @nogc and may require a @nogc delegate for this. An implementation of it may not require a @nogc delegate in its internal logic, but by the reasoning explained in AfHOF, calling C.toString with a @nogc argument will result in a @nogc execution. ADA is similar (as far as I can tell): one would replace the @nogc of C.toString by @nogc(*). --
