sociomantic-tsunami / ocean

General purpose, platform-dependent, high-performance library for D
Other
61 stars 56 forks source link

Deprecate module ocean.core.Traits #823

Closed Geod24 closed 4 years ago

codecov[bot] commented 4 years ago

Codecov Report

Merging #823 into v5.x.x will increase coverage by 0.07%. The diff coverage is n/a.

codecov[bot] commented 4 years ago

Codecov Report

Merging #823 into v5.x.x will increase coverage by 0.07%. The diff coverage is n/a.

don-clugston-sociomantic commented 4 years ago

It turns out that this template doesn't actually have a replacement.

deprecated("Use ocean.meta.types.Function.ReturnTypeOf")
template ReturnTypeOf( alias fn )
{
    alias ReturnTypeOf!(typeof(fn)) ReturnTypeOf;
}

The code in ocean.core.Traits works for member functions. The one in meta does not, because it ignores the 'this' pointer.

This is used in dhtproto.

Geod24 commented 4 years ago

Do you have a link ? Github doesn't match anything.

don-clugston-sociomantic commented 4 years ago

It is in dhtproto.client.internal.NodeHashRanges

The relevant code is:

private class NodeHashRangesBase
{
    import ocean.meta.types.Function : ReturnTypeOf;
    import swarm.neo.AddrPort;

    /// Convenience alias for the comparison type of AddrPort.
    private alias ReturnTypeOf!(AddrPort.cmp_id) Addr;

And swarm.neo.AddrPort is:

public struct AddrPort
{
    public long cmp_id ( )  { .. }
}

I get: ./submodules/ocean/src/ocean/meta/types/Function.d(112): Error: need this for cmp_id of type long()

Geod24 commented 4 years ago

Can you try:

    private alias ReturnTypeOf!(&AddrPort.cmp_id) Addr;

From your error message, it looks like the method is implicitly called...

don-clugston-sociomantic commented 4 years ago

That doesn't work either.

./src/dhtproto/client/internal/NodeHashRanges.d(278): Error: expression & cmp_id is not a valid template value argument

Geod24 commented 4 years ago

Submitted a PR to fix the code, so merging this.