mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Remove ConstraintSystem::ImplicitValueConversions
This commit is contained in:
@@ -54,7 +54,6 @@ LOCATOR_CHANGE(RecordedOpenedExistentialType, OpenedExistentialTypes)
|
||||
LOCATOR_CHANGE(RecordedPackExpansionEnvironment, PackExpansionEnvironments)
|
||||
LOCATOR_CHANGE(RecordedDefaultedConstraint, DefaultedConstraints)
|
||||
LOCATOR_CHANGE(ResolvedOverload, ResolvedOverloads)
|
||||
LOCATOR_CHANGE(RecordedImplicitValueConversion, ImplicitValueConversions)
|
||||
LOCATOR_CHANGE(RecordedArgumentList, ArgumentLists)
|
||||
LOCATOR_CHANGE(RecordedImplicitCallAsFunctionRoot, ImplicitCallAsFunctionRoots)
|
||||
LOCATOR_CHANGE(RecordedSynthesizedConformance, SynthesizedConformances)
|
||||
|
||||
@@ -1580,10 +1580,6 @@ public:
|
||||
/// The locators of \c Defaultable constraints whose defaults were used.
|
||||
llvm::DenseSet<ConstraintLocator *> DefaultedConstraints;
|
||||
|
||||
/// Implicit value conversions applied for a given locator.
|
||||
std::vector<std::pair<ConstraintLocator *, ConversionRestrictionKind>>
|
||||
ImplicitValueConversions;
|
||||
|
||||
/// The node -> type mappings introduced by this solution.
|
||||
llvm::DenseMap<ASTNode, Type> nodeTypes;
|
||||
|
||||
@@ -2368,11 +2364,6 @@ private:
|
||||
llvm::DenseMap<ConstraintLocator *, MatchCallArgumentResult>
|
||||
argumentMatchingChoices;
|
||||
|
||||
/// The set of implicit value conversions performed by the solver on
|
||||
/// a current path to reach a solution.
|
||||
llvm::SmallDenseMap<ConstraintLocator *, ConversionRestrictionKind, 2>
|
||||
ImplicitValueConversions;
|
||||
|
||||
/// The worklist of "active" constraints that should be revisited
|
||||
/// due to a change.
|
||||
ConstraintList ActiveConstraints;
|
||||
@@ -5046,10 +5037,6 @@ private:
|
||||
TypeMatchOptions flags,
|
||||
ConstraintLocatorBuilder locator);
|
||||
|
||||
/// Update ImplicitValueConversions and record a change in the trail.
|
||||
void recordImplicitValueConversion(ConstraintLocator *locator,
|
||||
ConversionRestrictionKind restriction);
|
||||
|
||||
/// Simplify a conversion constraint by applying the given
|
||||
/// reduction rule, which is known to apply at the outermost level.
|
||||
SolutionKind simplifyRestrictedConstraint(
|
||||
|
||||
@@ -14263,17 +14263,6 @@ void ConstraintSystem::addRestrictedConstraint(
|
||||
TMF_GenerateConstraints, locator);
|
||||
}
|
||||
|
||||
void ConstraintSystem::recordImplicitValueConversion(
|
||||
ConstraintLocator *locator,
|
||||
ConversionRestrictionKind restriction) {
|
||||
bool inserted = ImplicitValueConversions.insert(
|
||||
{getConstraintLocator(locator), restriction}).second;
|
||||
ASSERT(inserted);
|
||||
|
||||
if (solverState)
|
||||
recordChange(SolverTrail::Change::RecordedImplicitValueConversion(locator));
|
||||
}
|
||||
|
||||
/// Given that we have a conversion constraint between two types, and
|
||||
/// that the given constraint-reduction rule applies between them at
|
||||
/// the top level, apply it and generate any necessary recursive
|
||||
@@ -14850,45 +14839,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
|
||||
if (worseThanBestSolution())
|
||||
return SolutionKind::Error;
|
||||
|
||||
auto *conversionLoc =
|
||||
getImplicitValueConversionLocator(locator, restriction);
|
||||
|
||||
auto *applicationLoc =
|
||||
getConstraintLocator(conversionLoc, ConstraintLocator::ApplyFunction);
|
||||
|
||||
auto *memberLoc = getConstraintLocator(
|
||||
applicationLoc, ConstraintLocator::ConstructorMember);
|
||||
|
||||
// Allocate a single argument info to cover all possible
|
||||
// Double <-> CGFloat conversion locations.
|
||||
auto *argumentsLoc =
|
||||
getConstraintLocator(conversionLoc, ConstraintLocator::ApplyArgument);
|
||||
|
||||
if (!ArgumentLists.count(argumentsLoc)) {
|
||||
auto *argList = ArgumentList::createImplicit(
|
||||
getASTContext(), {Argument(SourceLoc(), Identifier(), nullptr)},
|
||||
/*firstTrailingClosureIndex=*/std::nullopt,
|
||||
AllocationArena::ConstraintSolver);
|
||||
recordArgumentList(argumentsLoc, argList);
|
||||
}
|
||||
|
||||
auto *memberTypeLoc = getConstraintLocator(
|
||||
applicationLoc, LocatorPathElt::ConstructorMemberType());
|
||||
|
||||
auto *memberTy = createTypeVariable(memberTypeLoc, TVO_CanBindToNoEscape);
|
||||
|
||||
addValueMemberConstraint(MetatypeType::get(type2, getASTContext()),
|
||||
DeclNameRef(DeclBaseName::createConstructor()),
|
||||
memberTy, DC,
|
||||
FunctionRefInfo::doubleBaseNameApply(),
|
||||
/*outerAlternatives=*/{}, memberLoc);
|
||||
|
||||
addConstraint(ConstraintKind::ApplicableFunction,
|
||||
FunctionType::get({FunctionType::Param(type1)}, type2),
|
||||
memberTy, applicationLoc);
|
||||
|
||||
ImplicitValueConversions.insert(
|
||||
{getConstraintLocator(locator), restriction});
|
||||
return SolutionKind::Solved;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,11 +243,6 @@ Solution ConstraintSystem::finalize() {
|
||||
solution.appliedPropertyWrappers.insert(appliedWrapper);
|
||||
}
|
||||
|
||||
// Remember implicit value conversions.
|
||||
for (const auto &valueConversion : ImplicitValueConversions) {
|
||||
solution.ImplicitValueConversions.push_back(valueConversion);
|
||||
}
|
||||
|
||||
// Remember argument lists.
|
||||
for (const auto &argListMapping : ArgumentLists) {
|
||||
solution.argumentLists.insert(argListMapping);
|
||||
@@ -445,13 +440,6 @@ void ConstraintSystem::replaySolution(const Solution &solution,
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &valueConversion : solution.ImplicitValueConversions) {
|
||||
if (ImplicitValueConversions.count(valueConversion.first) == 0) {
|
||||
recordImplicitValueConversion(valueConversion.first,
|
||||
valueConversion.second);
|
||||
}
|
||||
}
|
||||
|
||||
// Register the argument lists.
|
||||
for (auto &argListMapping : solution.argumentLists) {
|
||||
if (ArgumentLists.count(argListMapping.first) == 0)
|
||||
|
||||
@@ -23,23 +23,3 @@ func testOptional(obj: P) {
|
||||
_ = obj.opt?(1)
|
||||
}
|
||||
|
||||
|
||||
func test_double_cgfloat_conversion_filtering(d: Double, cgf: CGFloat) {
|
||||
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).CGFloat.init(_:)@{{.*}} : (CGFloat.Type) -> (Double) -> CGFloat
|
||||
let _: CGFloat = d
|
||||
|
||||
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).Double extension.init(_:)@{{.*}} : (Double.Type) -> (CGFloat) -> Double
|
||||
let _: Double = cgf
|
||||
|
||||
func test_optional_cgf(_: CGFloat??) {
|
||||
}
|
||||
|
||||
func test_optional_double(_: Double??) {
|
||||
}
|
||||
|
||||
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).CGFloat.init(_:)@{{.*}} : (CGFloat.Type) -> (Double) -> CGFloat
|
||||
test_optional_cgf(d)
|
||||
|
||||
// CHECK: [favored] $T{{.*}} bound to decl CoreGraphics.(file).Double extension.init(_:)@{{.*}} : (Double.Type) -> (CGFloat) -> Double
|
||||
test_optional_double(cgf)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user