mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CSGen] Remove ConstraintOptimizer and all favoring logic
This commit is contained in:
@@ -9760,7 +9760,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
// If this is true, we're using type construction syntax (Foo()) rather
|
||||
// than an explicit call to `init` (Foo.init()).
|
||||
bool isImplicitInit = false;
|
||||
TypeBase *favoredType = nullptr;
|
||||
if (memberName.isSimpleName(DeclBaseName::createConstructor())) {
|
||||
SmallVector<LocatorPathElt, 2> parts;
|
||||
if (auto anchor = memberLocator->getAnchor()) {
|
||||
@@ -9768,17 +9767,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
if (!path.empty())
|
||||
if (path.back().getKind() == ConstraintLocator::ConstructorMember)
|
||||
isImplicitInit = true;
|
||||
|
||||
if (auto *applyExpr = getAsExpr<ApplyExpr>(anchor)) {
|
||||
if (auto *argExpr = applyExpr->getArgs()->getUnlabeledUnaryExpr()) {
|
||||
favoredType = getFavoredType(argExpr);
|
||||
|
||||
if (!favoredType) {
|
||||
optimizeConstraints(argExpr);
|
||||
favoredType = getFavoredType(argExpr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9887,30 +9875,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
hasInstanceMethods = true;
|
||||
}
|
||||
|
||||
// If the invocation's argument expression has a favored type,
|
||||
// use that information to determine whether a specific overload for
|
||||
// the candidate should be favored.
|
||||
if (isa<ConstructorDecl>(decl) && favoredType &&
|
||||
result.FavoredChoice == ~0U) {
|
||||
auto *ctor = cast<ConstructorDecl>(decl);
|
||||
|
||||
// Only try and favor monomorphic unary initializers.
|
||||
if (!ctor->isGenericContext()) {
|
||||
if (!ctor->getMethodInterfaceType()->hasError()) {
|
||||
// The constructor might have an error type because we don't skip
|
||||
// invalid decls for code completion
|
||||
auto args = ctor->getMethodInterfaceType()
|
||||
->castTo<FunctionType>()
|
||||
->getParams();
|
||||
if (args.size() == 1 && !args[0].hasLabel() &&
|
||||
args[0].getPlainType()->isEqual(favoredType)) {
|
||||
if (!isDeclUnavailable(decl, memberLocator))
|
||||
result.FavoredChoice = result.ViableCandidates.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto isUnsupportedExistentialMemberAccess = [&] {
|
||||
// We may not be able to derive a well defined type for an existential
|
||||
// member access if the member's signature references 'Self'.
|
||||
|
||||
Reference in New Issue
Block a user