The output of the coding given is:
Reference: Child
source\test.d(11): Error: class app.Child member childStr is not accessible
true
source\app.d(8): Error: mixin app.Child.ComponentTemplate!() error instantiating
1.) Althoug childStr is not accessible the text "true" is shown
2.) By uncommenting the line, the output is as expected
module test;
enum isPublic(alias e) = __traits(getProtection, e) == "public";
template Params(this MyType)
{
string[] Params()
{
pragma(msg, "Reference: " ~ MyType.stringof);
/*pragma(msg, __traits(getProtection, __traits(getMember, MyType, "childStr")));*/
pragma(msg, isPublic!(__traits(getMember, MyType, "childStr")));
return [];
}
}
mixin template ComponentTemplate()
{
private enum parameters = Params!(typeof(this));
string[] getParameters()
{
return parameters;
}
}
class Parent
{
@property string parentStr(){return "";}
}
module app;
import std.stdio;
import test;
class Child : Parent
{
mixin ComponentTemplate;
@property string childStr(){return "";}
}
void main()
{
auto child = new Child();
writeln(child.getParameters());
}
Comment #1 by dlang-bugzilla — 2017-06-26T15:56:14Z
The example given compiles since https://github.com/dlang/dmd/pull/3841 was merged, so I believe this to be a duplicate of issue 13226.
*** This issue has been marked as a duplicate of issue 13226 ***