Skip to content

Commit 4ae57ac

Browse files
committed
Sema: Remove ConstraintSystem::ImplicitValueConversions
1 parent 0c2887d commit 4ae57ac

File tree

5 files changed

+0
-96
lines changed

5 files changed

+0
-96
lines changed

include/swift/Sema/CSTrail.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ LOCATOR_CHANGE(RecordedOpenedExistentialType, OpenedExistentialTypes)
5454
LOCATOR_CHANGE(RecordedPackExpansionEnvironment, PackExpansionEnvironments)
5555
LOCATOR_CHANGE(RecordedDefaultedConstraint, DefaultedConstraints)
5656
LOCATOR_CHANGE(ResolvedOverload, ResolvedOverloads)
57-
LOCATOR_CHANGE(RecordedImplicitValueConversion, ImplicitValueConversions)
5857
LOCATOR_CHANGE(RecordedArgumentList, ArgumentLists)
5958
LOCATOR_CHANGE(RecordedImplicitCallAsFunctionRoot, ImplicitCallAsFunctionRoots)
6059
LOCATOR_CHANGE(RecordedSynthesizedConformance, SynthesizedConformances)

include/swift/Sema/ConstraintSystem.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,10 +1580,6 @@ class Solution {
15801580
/// The locators of \c Defaultable constraints whose defaults were used.
15811581
llvm::DenseSet<ConstraintLocator *> DefaultedConstraints;
15821582

1583-
/// Implicit value conversions applied for a given locator.
1584-
std::vector<std::pair<ConstraintLocator *, ConversionRestrictionKind>>
1585-
ImplicitValueConversions;
1586-
15871583
/// The node -> type mappings introduced by this solution.
15881584
llvm::DenseMap<ASTNode, Type> nodeTypes;
15891585

@@ -2368,11 +2364,6 @@ class ConstraintSystem {
23682364
llvm::DenseMap<ConstraintLocator *, MatchCallArgumentResult>
23692365
argumentMatchingChoices;
23702366

2371-
/// The set of implicit value conversions performed by the solver on
2372-
/// a current path to reach a solution.
2373-
llvm::SmallDenseMap<ConstraintLocator *, ConversionRestrictionKind, 2>
2374-
ImplicitValueConversions;
2375-
23762367
/// The worklist of "active" constraints that should be revisited
23772368
/// due to a change.
23782369
ConstraintList ActiveConstraints;
@@ -5046,10 +5037,6 @@ class ConstraintSystem {
50465037
TypeMatchOptions flags,
50475038
ConstraintLocatorBuilder locator);
50485039

5049-
/// Update ImplicitValueConversions and record a change in the trail.
5050-
void recordImplicitValueConversion(ConstraintLocator *locator,
5051-
ConversionRestrictionKind restriction);
5052-
50535040
/// Simplify a conversion constraint by applying the given
50545041
/// reduction rule, which is known to apply at the outermost level.
50555042
SolutionKind simplifyRestrictedConstraint(

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14263,17 +14263,6 @@ void ConstraintSystem::addRestrictedConstraint(
1426314263
TMF_GenerateConstraints, locator);
1426414264
}
1426514265

14266-
void ConstraintSystem::recordImplicitValueConversion(
14267-
ConstraintLocator *locator,
14268-
ConversionRestrictionKind restriction) {
14269-
bool inserted = ImplicitValueConversions.insert(
14270-
{getConstraintLocator(locator), restriction}).second;
14271-
ASSERT(inserted);
14272-
14273-
if (solverState)
14274-
recordChange(SolverTrail::Change::RecordedImplicitValueConversion(locator));
14275-
}
14276-
1427714266
/// Given that we have a conversion constraint between two types, and
1427814267
/// that the given constraint-reduction rule applies between them at
1427914268
/// the top level, apply it and generate any necessary recursive
@@ -14850,45 +14839,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
1485014839
if (worseThanBestSolution())
1485114840
return SolutionKind::Error;
1485214841

14853-
auto *conversionLoc =
14854-
getImplicitValueConversionLocator(locator, restriction);
14855-
14856-
auto *applicationLoc =
14857-
getConstraintLocator(conversionLoc, ConstraintLocator::ApplyFunction);
14858-
14859-
auto *memberLoc = getConstraintLocator(
14860-
applicationLoc, ConstraintLocator::ConstructorMember);
14861-
14862-
// Allocate a single argument info to cover all possible
14863-
// Double <-> CGFloat conversion locations.
14864-
auto *argumentsLoc =
14865-
getConstraintLocator(conversionLoc, ConstraintLocator::ApplyArgument);
14866-
14867-
if (!ArgumentLists.count(argumentsLoc)) {
14868-
auto *argList = ArgumentList::createImplicit(
14869-
getASTContext(), {Argument(SourceLoc(), Identifier(), nullptr)},
14870-
/*firstTrailingClosureIndex=*/std::nullopt,
14871-
AllocationArena::ConstraintSolver);
14872-
recordArgumentList(argumentsLoc, argList);
14873-
}
14874-
14875-
auto *memberTypeLoc = getConstraintLocator(
14876-
applicationLoc, LocatorPathElt::ConstructorMemberType());
14877-
14878-
auto *memberTy = createTypeVariable(memberTypeLoc, TVO_CanBindToNoEscape);
14879-
14880-
addValueMemberConstraint(MetatypeType::get(type2, getASTContext()),
14881-
DeclNameRef(DeclBaseName::createConstructor()),
14882-
memberTy, DC,
14883-
FunctionRefInfo::doubleBaseNameApply(),
14884-
/*outerAlternatives=*/{}, memberLoc);
14885-
14886-
addConstraint(ConstraintKind::ApplicableFunction,
14887-
FunctionType::get({FunctionType::Param(type1)}, type2),
14888-
memberTy, applicationLoc);
14889-
14890-
ImplicitValueConversions.insert(
14891-
{getConstraintLocator(locator), restriction});
1489214842
return SolutionKind::Solved;
1489314843
}
1489414844
}

lib/Sema/CSSolver.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,6 @@ Solution ConstraintSystem::finalize() {
243243
solution.appliedPropertyWrappers.insert(appliedWrapper);
244244
}
245245

246-
// Remember implicit value conversions.
247-
for (const auto &valueConversion : ImplicitValueConversions) {
248-
solution.ImplicitValueConversions.push_back(valueConversion);
249-
}
250-
251246
// Remember argument lists.
252247
for (const auto &argListMapping : ArgumentLists) {
253248
solution.argumentLists.insert(argListMapping);
@@ -445,13 +440,6 @@ void ConstraintSystem::replaySolution(const Solution &solution,
445440
}
446441
}
447442

448-
for (auto &valueConversion : solution.ImplicitValueConversions) {
449-
if (ImplicitValueConversions.count(valueConversion.first) == 0) {
450-
recordImplicitValueConversion(valueConversion.first,
451-
valueConversion.second);
452-
}
453-
}
454-
455443
// Register the argument lists.
456444
for (auto &argListMapping : solution.argumentLists) {
457445
if (ArgumentLists.count(argListMapping.first) == 0)

test/Constraints/overload_filtering_objc.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,3 @@ func testOptional(obj: P) {
2323
_ = obj.opt?(1)
2424
}
2525

26-
27-
func test_double_cgfloat_conversion_filtering(d: Double, cgf: CGFloat) {
28-
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).CGFloat.init(_:)@{{.*}} : (CGFloat.Type) -> (Double) -> CGFloat
29-
let _: CGFloat = d
30-
31-
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).Double extension.init(_:)@{{.*}} : (Double.Type) -> (CGFloat) -> Double
32-
let _: Double = cgf
33-
34-
func test_optional_cgf(_: CGFloat??) {
35-
}
36-
37-
func test_optional_double(_: Double??) {
38-
}
39-
40-
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).CGFloat.init(_:)@{{.*}} : (CGFloat.Type) -> (Double) -> CGFloat
41-
test_optional_cgf(d)
42-
43-
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).Double extension.init(_:)@{{.*}} : (Double.Type) -> (CGFloat) -> Double
44-
test_optional_double(cgf)
45-
}

0 commit comments

Comments
 (0)