[Issue 16410] attribute inference inside templated classes

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 21 08:05:42 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16410

--- Comment #5 from Lodovico Giaretta <lodovico at giaretart.net> ---
(In reply to b2.temp from comment #4)
> but auto return type is made for this case, i.e when attribute inference is
> needed.

The problem is that I'm in this situation:

==========================
interface Foo
{
    int doSomething();
}
class Bar(T): Foo
{
    override int doSomething()
    {
        // do something with T
    }
}
==========================

There's no way to have Bar.doSomething @nogc currently because
1) I cannot put @nogc on Foo.doSomething, because in general it is not @nogc.
2) I cannot put @nogc on Bar.doSomething, because it may use the gc depending
on T
3) I cannot use the "auto return trick" to trigger inference, because auto
return cannot be used with override.

So currently there's no way to use Bar!T in @nogc code even for T's that are
@nogc.

--


More information about the Digitalmars-d-bugs mailing list