Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions include/swift/Sema/ConstraintLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1013,26 +1013,6 @@ class LocatorPathElt::PlaceholderType final
}
};

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)
Expand Down
3 changes: 0 additions & 3 deletions include/swift/Sema/ConstraintLocatorPathElts.def
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 0 additions & 6 deletions include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
15 changes: 1 addition & 14 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
};
Expand Down
7 changes: 0 additions & 7 deletions lib/Sema/ConstraintLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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) << "'";
Expand Down
46 changes: 0 additions & 46 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
{
Expand Down Expand Up @@ -3908,9 +3868,6 @@ void constraints::simplifyLocator(ASTNode &anchor,
break;
}

case ConstraintLocator::ImplicitConversion:
break;

case ConstraintLocator::Witness:
case ConstraintLocator::WrappedValue:
case ConstraintLocator::OptionalInjection:
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 0 additions & 7 deletions lib/Sema/TypeOfReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down