Skip to content

Commit

Permalink
spec change and changelog entry for Issue 15907
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Aug 24, 2016
1 parent 37f4dee commit deb87b7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
54 changes: 53 additions & 1 deletion changelog/2.071.2_pre.dd
Expand Up @@ -4,7 +4,59 @@ $(CHANGELOG_NAV_LAST 2.071.1)

$(VERSION August 7, 2016, =================================================,

$(BR)$(BIG List of all bug fixes and enhancements in D $(VER):)
$(BUGSTITLE Language Changes,
$(LI $(RELATIVE_LINK2 traits-members-visibility, The `allMembers` and `derivedMembers` traits now only return visible symbols.))
)

$(BR)$(BIG $(RELATIVE_LINK2 bugfix-list, List of all bug fixes and enhancements in D $(VER).))

$(HR)

$(BUGSTITLE Language Changes,
$(LI $(LNAME2 traits-members-visibility, The `allMembers` and `derivedMembers` traits now only return visible symbols.))

$(P Since changing the protection system from access to visibility checks
(see $(DDSUBLINK changelog/2.071.0, dip22, DIP22)), using the
$(DDSUBLINK spec/traits, getMember, `getMember`) traits would often
result in nonsense deprecation warnings for invisible (private) symbols
in $(DDSUBLINK spec/traits, allMembers, `allMembers`) or
$(DDSUBLINK spec/traits, derivedMembers, `derivedMembers`). As the symbols
weren't accessible before and are now invisible, the implementation of the
traits was changed to no longer list those.
)

$(P To ease updating existing code, the old behavior can be restored using
the `-transition=import` compiler switch.
)

$(P In case you want a template from a library to return private members,
you can mixin the template into the instantiation scope. Note that it's
possible to mixin normal templates even though they're not declared as
mixin template.
)

$(P Example:)
---
import std.traits;
enum UDA;
struct S
{
@UDA int visible;
@UDA private int invisible;
}
// only returns symbols visible from std.traits
static assert(getSymbolsByUDA!(S, UDA).length == 1);
// mixin the template instantiation, using a name to avoid namespace pollution
mixin getSymbolsByUDA!(S, UDA) symbols;
// as the template is instantiated in the current scope, it can see private members
static assert(symbols.getSymbolsByUDA.length == 2);
---

$(P See also $(BUGZILLA 15907))
)
)

$(BR)$(BIG $(LNAME2 bugfix-list, List of all bug fixes and enhancements in D $(VER):))

$(BUGSTITLE DMD Compiler regressions,

Expand Down
2 changes: 2 additions & 0 deletions spec/traits.dd
Expand Up @@ -801,6 +801,7 @@ $(H2 $(GNAME allMembers))
A tuple of string literals is returned, each of which
is the name of a member of that type combined with all
of the members of the base classes (if the type is a class).
Only members visible in the current scope are listed.
No name is repeated.
Builtin properties are not included.
)
Expand Down Expand Up @@ -833,6 +834,7 @@ $(H2 $(GNAME derivedMembers))
a type or an expression of type.
A tuple of string literals is returned, each of which
is the name of a member of that type.
Only members visible in the current scope are listed.
No name is repeated.
Base class member names are not included.
Builtin properties are not included.
Expand Down

0 comments on commit deb87b7

Please sign in to comment.