[CS] Remove getImplicitValueConversionLocator & ImplicitConversion

These are now unused.
This commit is contained in:
Hamish Knight
2025-11-15 19:04:04 +00:00
parent 2a0172d25a
commit 6dfff1ce9c
7 changed files with 1 additions and 103 deletions

View File

@@ -1013,26 +1013,6 @@ public:
}
};
class LocatorPathElt::ImplicitConversion final
: public StoredIntegerElement<1> {
public:
ImplicitConversion(ConversionRestrictionKind kind)
: StoredIntegerElement(ConstraintLocator::ImplicitConversion,
static_cast<unsigned>(kind)) {}
ConversionRestrictionKind getConversionKind() const {
return static_cast<ConversionRestrictionKind>(getValue());
}
bool is(ConversionRestrictionKind kind) const {
return getConversionKind() == kind;
}
static bool classof(const LocatorPathElt *elt) {
return elt->getKind() == ConstraintLocator::ImplicitConversion;
}
};
class LocatorPathElt::ContextualType final : public StoredIntegerElement<1> {
public:
ContextualType(ContextualTypePurpose purpose)

View File

@@ -252,9 +252,6 @@ CUSTOM_LOCATOR_PATH_ELT(ConformanceRequirement)
/// A source-specified placeholder.
CUSTOM_LOCATOR_PATH_ELT(PlaceholderType)
/// The implicit conversion applied at a given location.
CUSTOM_LOCATOR_PATH_ELT(ImplicitConversion)
/// An implicit call to a 'dynamicMember' subscript for a dynamic member lookup.
SIMPLE_LOCATOR_PATH_ELT(ImplicitDynamicMemberSubscript)

View File

@@ -3393,12 +3393,6 @@ public:
ConstraintLocator *
getConstraintLocator(const ConstraintLocatorBuilder &builder);
/// Compute a constraint locator for an implicit value-to-value
/// conversion rooted at the given location.
ConstraintLocator *
getImplicitValueConversionLocator(ConstraintLocatorBuilder root,
ConversionRestrictionKind restriction);
/// Lookup and return parent associated with given expression.
Expr *getParentExpr(Expr *expr) {
if (auto result = getExprDepthAndParent(expr))

View File

@@ -7739,16 +7739,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
isExpr<ForcedCheckedCastExpr>(anchor);
};
if (!isCGFloatInit(anchor) && !isCoercionOrCast(anchor, path) &&
llvm::none_of(path, [&](const LocatorPathElt &rawElt) {
if (auto elt =
rawElt.getAs<LocatorPathElt::ImplicitConversion>()) {
auto convKind = elt->getConversionKind();
return convKind == ConversionRestrictionKind::DoubleToCGFloat ||
convKind == ConversionRestrictionKind::CGFloatToDouble;
}
return false;
})) {
if (!isCGFloatInit(anchor) && !isCoercionOrCast(anchor, path)) {
conversionsOrFixes.push_back(
desugar1->isCGFloat()
? ConversionRestrictionKind::CGFloatToDouble
@@ -11031,10 +11022,6 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
if (!anchor)
return nullptr;
// Avoid checking implicit conversions injected by the compiler.
if (locator->findFirst<LocatorPathElt::ImplicitConversion>())
return nullptr;
auto getType = [&cs](Expr *expr) -> Type {
return cs.simplifyType(cs.getType(expr))->getRValueType();
};

View File

@@ -95,7 +95,6 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
case ConstraintLocator::ArgumentAttribute:
case ConstraintLocator::UnresolvedMemberChainResult:
case ConstraintLocator::PlaceholderType:
case ConstraintLocator::ImplicitConversion:
case ConstraintLocator::ImplicitDynamicMemberSubscript:
case ConstraintLocator::SyntacticElement:
case ConstraintLocator::PackType:
@@ -461,12 +460,6 @@ void LocatorPathElt::dump(raw_ostream &out) const {
out << "implicit dynamic member subscript";
break;
case ConstraintLocator::ConstraintLocator::ImplicitConversion: {
auto convElt = elt.castTo<LocatorPathElt::ImplicitConversion>();
out << "implicit conversion " << getName(convElt.getConversionKind());
break;
}
case ConstraintLocator::ConstraintLocator::PackType: {
auto packElt = elt.castTo<LocatorPathElt::PackType>();
out << "pack type '" << packElt.getType()->getString(PO) << "'";

View File

@@ -677,52 +677,12 @@ ConstraintLocator *ConstraintSystem::getConstraintLocator(
return getConstraintLocator(anchor, newPath);
}
ConstraintLocator *ConstraintSystem::getImplicitValueConversionLocator(
ConstraintLocatorBuilder root, ConversionRestrictionKind restriction) {
SmallVector<LocatorPathElt, 4> path;
auto anchor = root.getLocatorParts(path);
{
if (isExpr<DictionaryExpr>(anchor) && path.size() > 1) {
// Drop everything except for first `tuple element #`.
path.pop_back_n(path.size() - 1);
}
// Drop any value-to-optional conversions that were applied along the
// way to reach this one.
while (!path.empty()) {
if (path.back().is<LocatorPathElt::OptionalInjection>()) {
path.pop_back();
continue;
}
break;
}
// If conversion is for a tuple element, let's drop `TupleType`
// components from the path since they carry information for
// diagnostics that `ExprRewriter` won't be able to re-construct
// during solution application.
if (!path.empty() && path.back().is<LocatorPathElt::TupleElement>()) {
path.erase(llvm::remove_if(path,
[](const LocatorPathElt &elt) {
return elt.is<LocatorPathElt::TupleType>();
}),
path.end());
}
}
return getConstraintLocator(/*base=*/getConstraintLocator(anchor, path),
LocatorPathElt::ImplicitConversion(restriction));
}
ConstraintLocator *ConstraintSystem::getCalleeLocator(
ConstraintLocator *locator, bool lookThroughApply,
llvm::function_ref<Type(Expr *)> getType,
llvm::function_ref<Type(Type)> simplifyType,
llvm::function_ref<std::optional<SelectedOverload>(ConstraintLocator *)>
getOverloadFor) {
if (locator->findLast<LocatorPathElt::ImplicitConversion>())
return locator;
auto anchor = locator->getAnchor();
auto path = locator->getPath();
{
@@ -3908,9 +3868,6 @@ void constraints::simplifyLocator(ASTNode &anchor,
break;
}
case ConstraintLocator::ImplicitConversion:
break;
case ConstraintLocator::Witness:
case ConstraintLocator::WrappedValue:
case ConstraintLocator::OptionalInjection:
@@ -4064,9 +4021,6 @@ ConstraintSystem::getArgumentInfoLocator(ConstraintLocator *locator) {
if (anchor.isNull() && locator->getPath().empty())
return nullptr;
if (locator->findLast<LocatorPathElt::ImplicitConversion>())
return locator;
// Applies and unresolved member exprs can have callee locators that are
// dependent on the type of their function, which may not have been resolved
// yet. Therefore we need to handle them specially.

View File

@@ -2580,13 +2580,6 @@ static std::pair<bool, unsigned>
isInvalidPartialApplication(ConstraintSystem &cs,
const AbstractFunctionDecl *member,
ConstraintLocator *locator) {
// If this is a compiler synthesized implicit conversion, let's skip
// the check because the base of `UDE` is not the base of the injected
// initializer.
if (locator->isLastElement<LocatorPathElt::ConstructorMember>() &&
locator->findFirst<LocatorPathElt::ImplicitConversion>())
return {false, 0};
auto *UDE = getAsExpr<UnresolvedDotExpr>(locator->getAnchor());
if (UDE == nullptr)
return {false,0};