www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16347] New: Strange deprecation message when using templates


          Issue ID: 16347
           Summary: Strange deprecation message when using templates
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dev nomad.so

I'm not really sure what's going on here but here's a test snippet:

module test;

import std.traits;

public template DUnitMethodIterator(T, string generator, int index = 0)
    private string getResult()
        string code = "";
        static if (index < __traits(allMembers, T).length)
            // Comment out either the following static if to avoid the
deprecation message...
            static if (MemberFunctionsTuple!(T, __traits(allMembers,
T)[index]).length) { }

            // or the following template call to avoid the deprecation message.
            code ~= DUnitMethodIterator!(T, generator, index + 1);
        return code;
    enum DUnitMethodIterator = getResult();

private template MethodDelegateProperty(func...) { }

public mixin template Mockable(C)
    static public auto getMock(A...)(A args)
        return new Mock!(C)(args);

    private static class Mock(C)
        mixin(DUnitMethodIterator!(C, "MethodDelegateProperty!(func)"));

    static class T
        mixin Mockable!T;

    auto mock = T.getMock();

Building this code using the following command issues a deprecation message:

$ dmd -c -unittest test.d

/usr/include/dmd/phobos/std/traits.d(3677): Deprecation:
test.__unittestL40_1.T.Mockable!(T).Mock(C) if (is(C == class) || is(C ==
interface)) is not visible from module traits

Removing the commented lines of code (and rebuilding) removes the deprecation

Aug 01 2016