mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 08:00:48 +03:00

- change of __traits(allMembers) semantics cause getSymbolsByUDA to no longer return invisible (private) symbols - add test for using getSymbolsByUDA as mixin template to still access private symbols
26 lines
660 B
D
26 lines
660 B
D
/**
|
|
For testing only.
|
|
Provides a struct with UDA's defined in an external module.
|
|
Useful for validating behavior with member privacy.
|
|
*/
|
|
module std.internal.test.uda;
|
|
|
|
enum Attr;
|
|
|
|
struct HasPrivateMembers
|
|
{
|
|
@Attr int a;
|
|
int b;
|
|
@Attr private int c;
|
|
private int d;
|
|
}
|
|
|
|
// If getSymbolsByUDA is mixed into the same scope it also returns private members
|
|
unittest
|
|
{
|
|
import std.traits : getSymbolsByUDA, hasUDA;
|
|
mixin getSymbolsByUDA!(HasPrivateMembers, Attr) symbols;
|
|
static assert(symbols.getSymbolsByUDA.length == 2);
|
|
static assert(hasUDA!(symbols.getSymbolsByUDA[0], Attr));
|
|
static assert(hasUDA!(symbols.getSymbolsByUDA[1], Attr));
|
|
}
|