[Issue 24013] [REG 2.103.0] address of a __traits(getOverloads) item is not converted to a delegate anymore

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 26 08:22:41 UTC 2023


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #4 from RazvanN <razvan.nitu1305 at gmail.com> ---
Reduced test case:

```
struct PropDescriptor(T)
{
    void define(T delegate() aGetter, string aName) {}
}

enum Get;                                                                       

mixin template PropertyPublisherImpl()
{
    void collectPublicationsFromPairs(T)()
    {
        foreach (member; __traits(derivedMembers, T))
        foreach (overload; __traits(getOverloads, T, member))
        {
            alias Attributes = __traits(getAttributes, overload);
            static if (Attributes.length != 0)
            {
                auto descriptor = new PropDescriptor!ulong;
                auto dg = &overload;
                descriptor.define(dg, member);
            }
        }
    }
}

void main()
{
    class Bar
    {
        size_t _field;
        mixin PropertyPublisherImpl;
        this()
        {
            collectPublicationsFromPairs!Bar;
        }
        @Get size_t field()
        {
            return _field;
        }
    }
}
```

--


More information about the Digitalmars-d-bugs mailing list