diff --git a/include/swift/Sema/ConstraintLocator.h b/include/swift/Sema/ConstraintLocator.h index 3b6052e6df2e..f2228d9bcdde 100644 --- a/include/swift/Sema/ConstraintLocator.h +++ b/include/swift/Sema/ConstraintLocator.h @@ -1013,26 +1013,6 @@ class LocatorPathElt::PlaceholderType final } }; -class LocatorPathElt::ImplicitConversion final - : public StoredIntegerElement<1> { -public: - ImplicitConversion(ConversionRestrictionKind kind) - : StoredIntegerElement(ConstraintLocator::ImplicitConversion, - static_cast(kind)) {} - - ConversionRestrictionKind getConversionKind() const { - return static_cast(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) diff --git a/include/swift/Sema/ConstraintLocatorPathElts.def b/include/swift/Sema/ConstraintLocatorPathElts.def index a8b0bc15e55c..eeb7f5365d44 100644 --- a/include/swift/Sema/ConstraintLocatorPathElts.def +++ b/include/swift/Sema/ConstraintLocatorPathElts.def @@ -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) diff --git a/include/swift/Sema/ConstraintSystem.h b/include/swift/Sema/ConstraintSystem.h index 39fae6870932..505d31ad860d 100644 --- a/include/swift/Sema/ConstraintSystem.h +++ b/include/swift/Sema/ConstraintSystem.h @@ -3393,12 +3393,6 @@ class ConstraintSystem { 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)) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 21797bc5454b..5700d07079ba 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -7739,16 +7739,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind, isExpr(anchor); }; - if (!isCGFloatInit(anchor) && !isCoercionOrCast(anchor, path) && - llvm::none_of(path, [&](const LocatorPathElt &rawElt) { - if (auto elt = - rawElt.getAs()) { - 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()) - return nullptr; - auto getType = [&cs](Expr *expr) -> Type { return cs.simplifyType(cs.getType(expr))->getRValueType(); }; diff --git a/lib/Sema/ConstraintLocator.cpp b/lib/Sema/ConstraintLocator.cpp index 2cf038ea98be..6235fde61b3f 100644 --- a/lib/Sema/ConstraintLocator.cpp +++ b/lib/Sema/ConstraintLocator.cpp @@ -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(); - out << "implicit conversion " << getName(convElt.getConversionKind()); - break; - } - case ConstraintLocator::ConstraintLocator::PackType: { auto packElt = elt.castTo(); out << "pack type '" << packElt.getType()->getString(PO) << "'"; diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index 9701c4005add..9e3e542b13f6 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -677,52 +677,12 @@ ConstraintLocator *ConstraintSystem::getConstraintLocator( return getConstraintLocator(anchor, newPath); } -ConstraintLocator *ConstraintSystem::getImplicitValueConversionLocator( - ConstraintLocatorBuilder root, ConversionRestrictionKind restriction) { - SmallVector path; - auto anchor = root.getLocatorParts(path); - { - if (isExpr(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()) { - 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()) { - path.erase(llvm::remove_if(path, - [](const LocatorPathElt &elt) { - return elt.is(); - }), - path.end()); - } - } - - return getConstraintLocator(/*base=*/getConstraintLocator(anchor, path), - LocatorPathElt::ImplicitConversion(restriction)); -} - ConstraintLocator *ConstraintSystem::getCalleeLocator( ConstraintLocator *locator, bool lookThroughApply, llvm::function_ref getType, llvm::function_ref simplifyType, llvm::function_ref(ConstraintLocator *)> getOverloadFor) { - if (locator->findLast()) - 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()) - 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. diff --git a/lib/Sema/TypeOfReference.cpp b/lib/Sema/TypeOfReference.cpp index ade219eaffa1..7b35d04c68fe 100644 --- a/lib/Sema/TypeOfReference.cpp +++ b/lib/Sema/TypeOfReference.cpp @@ -2580,13 +2580,6 @@ static std::pair 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() && - locator->findFirst()) - return {false, 0}; - auto *UDE = getAsExpr(locator->getAnchor()); if (UDE == nullptr) return {false,0};