Add @_disfavoredOverload attribute to affect overload resolution.

Introduce an attribute @_disfavoredOverload that can be used to state
that a particular declaration should be avoided if there is a
successful type-check for a non-@_disfavoredOverload. It's a way to
nudge overload resolution away from particular solutions.
This commit is contained in:
Doug Gregor
2019-05-14 22:03:08 -07:00
parent 54d3930ae8
commit 5aea1315cd
9 changed files with 60 additions and 0 deletions

View File

@@ -641,6 +641,7 @@ namespace {
continue;
if (!decl->getAttrs().isUnavailable(CS.getASTContext()) &&
!decl->getAttrs().hasAttribute<DisfavoredOverloadAttr>() &&
isFavored(decl, overloadType)) {
// If we might need to roll back the favored constraints, keep
// track of those we are favoring.