Skip to content

Commit 6dfff1c

Browse files
committed
[CS] Remove getImplicitValueConversionLocator & ImplicitConversion
These are now unused.
1 parent 2a0172d commit 6dfff1c

File tree

7 files changed

+1
-103
lines changed

7 files changed

+1
-103
lines changed

include/swift/Sema/ConstraintLocator.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,26 +1013,6 @@ class LocatorPathElt::PlaceholderType final
10131013
}
10141014
};
10151015

1016-
class LocatorPathElt::ImplicitConversion final
1017-
: public StoredIntegerElement<1> {
1018-
public:
1019-
ImplicitConversion(ConversionRestrictionKind kind)
1020-
: StoredIntegerElement(ConstraintLocator::ImplicitConversion,
1021-
static_cast<unsigned>(kind)) {}
1022-
1023-
ConversionRestrictionKind getConversionKind() const {
1024-
return static_cast<ConversionRestrictionKind>(getValue());
1025-
}
1026-
1027-
bool is(ConversionRestrictionKind kind) const {
1028-
return getConversionKind() == kind;
1029-
}
1030-
1031-
static bool classof(const LocatorPathElt *elt) {
1032-
return elt->getKind() == ConstraintLocator::ImplicitConversion;
1033-
}
1034-
};
1035-
10361016
class LocatorPathElt::ContextualType final : public StoredIntegerElement<1> {
10371017
public:
10381018
ContextualType(ContextualTypePurpose purpose)

include/swift/Sema/ConstraintLocatorPathElts.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,6 @@ CUSTOM_LOCATOR_PATH_ELT(ConformanceRequirement)
252252
/// A source-specified placeholder.
253253
CUSTOM_LOCATOR_PATH_ELT(PlaceholderType)
254254

255-
/// The implicit conversion applied at a given location.
256-
CUSTOM_LOCATOR_PATH_ELT(ImplicitConversion)
257-
258255
/// An implicit call to a 'dynamicMember' subscript for a dynamic member lookup.
259256
SIMPLE_LOCATOR_PATH_ELT(ImplicitDynamicMemberSubscript)
260257

include/swift/Sema/ConstraintSystem.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,12 +3393,6 @@ class ConstraintSystem {
33933393
ConstraintLocator *
33943394
getConstraintLocator(const ConstraintLocatorBuilder &builder);
33953395

3396-
/// Compute a constraint locator for an implicit value-to-value
3397-
/// conversion rooted at the given location.
3398-
ConstraintLocator *
3399-
getImplicitValueConversionLocator(ConstraintLocatorBuilder root,
3400-
ConversionRestrictionKind restriction);
3401-
34023396
/// Lookup and return parent associated with given expression.
34033397
Expr *getParentExpr(Expr *expr) {
34043398
if (auto result = getExprDepthAndParent(expr))

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7739,16 +7739,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
77397739
isExpr<ForcedCheckedCastExpr>(anchor);
77407740
};
77417741

7742-
if (!isCGFloatInit(anchor) && !isCoercionOrCast(anchor, path) &&
7743-
llvm::none_of(path, [&](const LocatorPathElt &rawElt) {
7744-
if (auto elt =
7745-
rawElt.getAs<LocatorPathElt::ImplicitConversion>()) {
7746-
auto convKind = elt->getConversionKind();
7747-
return convKind == ConversionRestrictionKind::DoubleToCGFloat ||
7748-
convKind == ConversionRestrictionKind::CGFloatToDouble;
7749-
}
7750-
return false;
7751-
})) {
7742+
if (!isCGFloatInit(anchor) && !isCoercionOrCast(anchor, path)) {
77527743
conversionsOrFixes.push_back(
77537744
desugar1->isCGFloat()
77547745
? ConversionRestrictionKind::CGFloatToDouble
@@ -11031,10 +11022,6 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
1103111022
if (!anchor)
1103211023
return nullptr;
1103311024

11034-
// Avoid checking implicit conversions injected by the compiler.
11035-
if (locator->findFirst<LocatorPathElt::ImplicitConversion>())
11036-
return nullptr;
11037-
1103811025
auto getType = [&cs](Expr *expr) -> Type {
1103911026
return cs.simplifyType(cs.getType(expr))->getRValueType();
1104011027
};

lib/Sema/ConstraintLocator.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
9595
case ConstraintLocator::ArgumentAttribute:
9696
case ConstraintLocator::UnresolvedMemberChainResult:
9797
case ConstraintLocator::PlaceholderType:
98-
case ConstraintLocator::ImplicitConversion:
9998
case ConstraintLocator::ImplicitDynamicMemberSubscript:
10099
case ConstraintLocator::SyntacticElement:
101100
case ConstraintLocator::PackType:
@@ -461,12 +460,6 @@ void LocatorPathElt::dump(raw_ostream &out) const {
461460
out << "implicit dynamic member subscript";
462461
break;
463462

464-
case ConstraintLocator::ConstraintLocator::ImplicitConversion: {
465-
auto convElt = elt.castTo<LocatorPathElt::ImplicitConversion>();
466-
out << "implicit conversion " << getName(convElt.getConversionKind());
467-
break;
468-
}
469-
470463
case ConstraintLocator::ConstraintLocator::PackType: {
471464
auto packElt = elt.castTo<LocatorPathElt::PackType>();
472465
out << "pack type '" << packElt.getType()->getString(PO) << "'";

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -677,52 +677,12 @@ ConstraintLocator *ConstraintSystem::getConstraintLocator(
677677
return getConstraintLocator(anchor, newPath);
678678
}
679679

680-
ConstraintLocator *ConstraintSystem::getImplicitValueConversionLocator(
681-
ConstraintLocatorBuilder root, ConversionRestrictionKind restriction) {
682-
SmallVector<LocatorPathElt, 4> path;
683-
auto anchor = root.getLocatorParts(path);
684-
{
685-
if (isExpr<DictionaryExpr>(anchor) && path.size() > 1) {
686-
// Drop everything except for first `tuple element #`.
687-
path.pop_back_n(path.size() - 1);
688-
}
689-
690-
// Drop any value-to-optional conversions that were applied along the
691-
// way to reach this one.
692-
while (!path.empty()) {
693-
if (path.back().is<LocatorPathElt::OptionalInjection>()) {
694-
path.pop_back();
695-
continue;
696-
}
697-
break;
698-
}
699-
700-
// If conversion is for a tuple element, let's drop `TupleType`
701-
// components from the path since they carry information for
702-
// diagnostics that `ExprRewriter` won't be able to re-construct
703-
// during solution application.
704-
if (!path.empty() && path.back().is<LocatorPathElt::TupleElement>()) {
705-
path.erase(llvm::remove_if(path,
706-
[](const LocatorPathElt &elt) {
707-
return elt.is<LocatorPathElt::TupleType>();
708-
}),
709-
path.end());
710-
}
711-
}
712-
713-
return getConstraintLocator(/*base=*/getConstraintLocator(anchor, path),
714-
LocatorPathElt::ImplicitConversion(restriction));
715-
}
716-
717680
ConstraintLocator *ConstraintSystem::getCalleeLocator(
718681
ConstraintLocator *locator, bool lookThroughApply,
719682
llvm::function_ref<Type(Expr *)> getType,
720683
llvm::function_ref<Type(Type)> simplifyType,
721684
llvm::function_ref<std::optional<SelectedOverload>(ConstraintLocator *)>
722685
getOverloadFor) {
723-
if (locator->findLast<LocatorPathElt::ImplicitConversion>())
724-
return locator;
725-
726686
auto anchor = locator->getAnchor();
727687
auto path = locator->getPath();
728688
{
@@ -3908,9 +3868,6 @@ void constraints::simplifyLocator(ASTNode &anchor,
39083868
break;
39093869
}
39103870

3911-
case ConstraintLocator::ImplicitConversion:
3912-
break;
3913-
39143871
case ConstraintLocator::Witness:
39153872
case ConstraintLocator::WrappedValue:
39163873
case ConstraintLocator::OptionalInjection:
@@ -4064,9 +4021,6 @@ ConstraintSystem::getArgumentInfoLocator(ConstraintLocator *locator) {
40644021
if (anchor.isNull() && locator->getPath().empty())
40654022
return nullptr;
40664023

4067-
if (locator->findLast<LocatorPathElt::ImplicitConversion>())
4068-
return locator;
4069-
40704024
// Applies and unresolved member exprs can have callee locators that are
40714025
// dependent on the type of their function, which may not have been resolved
40724026
// yet. Therefore we need to handle them specially.

lib/Sema/TypeOfReference.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,13 +2580,6 @@ static std::pair<bool, unsigned>
25802580
isInvalidPartialApplication(ConstraintSystem &cs,
25812581
const AbstractFunctionDecl *member,
25822582
ConstraintLocator *locator) {
2583-
// If this is a compiler synthesized implicit conversion, let's skip
2584-
// the check because the base of `UDE` is not the base of the injected
2585-
// initializer.
2586-
if (locator->isLastElement<LocatorPathElt::ConstructorMember>() &&
2587-
locator->findFirst<LocatorPathElt::ImplicitConversion>())
2588-
return {false, 0};
2589-
25902583
auto *UDE = getAsExpr<UnresolvedDotExpr>(locator->getAnchor());
25912584
if (UDE == nullptr)
25922585
return {false,0};

0 commit comments

Comments
 (0)