From deb87b753a455ae847389642d2835a9fb891ab5a Mon Sep 17 00:00:00 2001 From: Martin Nowak Date: Wed, 24 Aug 2016 18:53:30 +0200 Subject: [PATCH] spec change and changelog entry for Issue 15907 --- changelog/2.071.2_pre.dd | 54 +++++++++++++++++++++++++++++++++++++++- spec/traits.dd | 2 ++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/changelog/2.071.2_pre.dd b/changelog/2.071.2_pre.dd index 88d446a073..2a991db60f 100644 --- a/changelog/2.071.2_pre.dd +++ b/changelog/2.071.2_pre.dd @@ -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, diff --git a/spec/traits.dd b/spec/traits.dd index 60be2c82a5..92a50b807f 100644 --- a/spec/traits.dd +++ b/spec/traits.dd @@ -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. ) @@ -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.