Skip to content

Commit 1f32f7f

Browse files
authored
Merge pull request #85525 from hamishknight/yeet
[CS] Remove `getImplicitValueConversionLocator` & `ImplicitConversion`
2 parents 82f4a10 + 6dfff1c commit 1f32f7f

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
@@ -1010,26 +1010,6 @@ class LocatorPathElt::PlaceholderType final
10101010
}
10111011
};
10121012

1013-
class LocatorPathElt::ImplicitConversion final
1014-
: public StoredIntegerElement<1> {
1015-
public:
1016-
ImplicitConversion(ConversionRestrictionKind kind)
1017-
: StoredIntegerElement(ConstraintLocator::ImplicitConversion,
1018-
static_cast<unsigned>(kind)) {}
1019-
1020-
ConversionRestrictionKind getConversionKind() const {
1021-
return static_cast<ConversionRestrictionKind>(getValue());
1022-
}
1023-
1024-
bool is(ConversionRestrictionKind kind) const {
1025-
return getConversionKind() == kind;
1026-
}
1027-
1028-
static bool classof(const LocatorPathElt *elt) {
1029-
return elt->getKind() == ConstraintLocator::ImplicitConversion;
1030-
}
1031-
};
1032-
10331013
class LocatorPathElt::ContextualType final : public StoredIntegerElement<1> {
10341014
public:
10351015
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
@@ -7743,16 +7743,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
77437743
isExpr<ForcedCheckedCastExpr>(anchor);
77447744
};
77457745

7746-
if (!isCGFloatInit(anchor) && !isCoercionOrCast(anchor, path) &&
7747-
llvm::none_of(path, [&](const LocatorPathElt &rawElt) {
7748-
if (auto elt =
7749-
rawElt.getAs<LocatorPathElt::ImplicitConversion>()) {
7750-
auto convKind = elt->getConversionKind();
7751-
return convKind == ConversionRestrictionKind::DoubleToCGFloat ||
7752-
convKind == ConversionRestrictionKind::CGFloatToDouble;
7753-
}
7754-
return false;
7755-
})) {
7746+
if (!isCGFloatInit(anchor) && !isCoercionOrCast(anchor, path)) {
77567747
conversionsOrFixes.push_back(
77577748
desugar1->isCGFloat()
77587749
? ConversionRestrictionKind::CGFloatToDouble
@@ -11035,10 +11026,6 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
1103511026
if (!anchor)
1103611027
return nullptr;
1103711028

11038-
// Avoid checking implicit conversions injected by the compiler.
11039-
if (locator->findFirst<LocatorPathElt::ImplicitConversion>())
11040-
return nullptr;
11041-
1104211029
auto getType = [&cs](Expr *expr) -> Type {
1104311030
return cs.simplifyType(cs.getType(expr))->getRValueType();
1104411031
};

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
{
@@ -3909,9 +3869,6 @@ void constraints::simplifyLocator(ASTNode &anchor,
39093869
break;
39103870
}
39113871

3912-
case ConstraintLocator::ImplicitConversion:
3913-
break;
3914-
39153872
case ConstraintLocator::Witness:
39163873
case ConstraintLocator::WrappedValue:
39173874
case ConstraintLocator::ImplicitlyUnwrappedDisjunctionChoice:
@@ -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)