mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -2169,6 +2169,12 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
|
||||
<< boundType->getString() << " := "
|
||||
<< refType->getString() << ")\n";
|
||||
}
|
||||
|
||||
// If this overload is disfavored, note that.
|
||||
if (choice.isDecl() &&
|
||||
choice.getDecl()->getAttrs().hasAttribute<DisfavoredOverloadAttr>()) {
|
||||
increaseScore(SK_DisfavoredOverload);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
|
||||
Reference in New Issue
Block a user