Fix getSymbolsByUDA by replacing broad __traits(compiles) with a more narrow condition #8631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was discovered in dlang/dmd#14554.
hasUDA
usesgetUDAs
underneath which in turn usestraits(getAttributes)
. Up until dmd PR 14554getUDAs
would happily accept an overload set and because of the bug in__traits(getAttributes)
it would just check the first lexicographically overload encountered.getSymbolsByUDA
which useshasUDA
internally would first check ifhasUDA
is callalble on the members of the passed aggregate by using__traits(compiles, hasUDA!member)
. This was done to prevent callingtraits(getAttributes)
on types or alias sequences, however, with the new deprecation from dmd PR 14554 and since phobos compiles with -de the__traits(compiles)
check now fails for functions that have overloads, thus breakinggetSymbolsByUDA
.The fix is to narrow the condition by specifically checking for types and alias sequences in the internals of
getSymbolsByUDA
, which this PR does, thus unblocking dmd PR 14554.