mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Tiny cleanup for matchTypes()
This commit is contained in:
@@ -4608,16 +4608,15 @@ public:
|
||||
inline bool isFailure() const { return Kind == SolutionKind::Error; }
|
||||
inline bool isAmbiguous() const { return Kind == SolutionKind::Unsolved; }
|
||||
|
||||
static TypeMatchResult success(ConstraintSystem &cs) {
|
||||
static TypeMatchResult success() {
|
||||
return {SolutionKind::Solved};
|
||||
}
|
||||
|
||||
static TypeMatchResult failure(ConstraintSystem &cs,
|
||||
ConstraintLocatorBuilder location) {
|
||||
static TypeMatchResult failure() {
|
||||
return {SolutionKind::Error};
|
||||
}
|
||||
|
||||
static TypeMatchResult ambiguous(ConstraintSystem &cs) {
|
||||
static TypeMatchResult ambiguous() {
|
||||
return {SolutionKind::Unsolved};
|
||||
}
|
||||
|
||||
@@ -4722,15 +4721,15 @@ public: // FIXME: public due to statics in CSSimplify.cpp
|
||||
ConstraintLocatorBuilder locator);
|
||||
|
||||
TypeMatchResult getTypeMatchSuccess() {
|
||||
return TypeMatchResult::success(*this);
|
||||
return TypeMatchResult::success();
|
||||
}
|
||||
|
||||
TypeMatchResult getTypeMatchFailure(ConstraintLocatorBuilder locator) {
|
||||
return TypeMatchResult::failure(*this, locator);
|
||||
return TypeMatchResult::failure();
|
||||
}
|
||||
|
||||
TypeMatchResult getTypeMatchAmbiguous() {
|
||||
return TypeMatchResult::ambiguous(*this);
|
||||
return TypeMatchResult::ambiguous();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -7646,6 +7646,22 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
}
|
||||
}
|
||||
|
||||
if (kind == ConstraintKind::BindToPointerType) {
|
||||
if (desugar2->isEqual(getASTContext().TheEmptyTupleType))
|
||||
return getTypeMatchSuccess();
|
||||
}
|
||||
|
||||
if (kind == ConstraintKind::BindParam) {
|
||||
if (auto *iot = dyn_cast<InOutType>(desugar1)) {
|
||||
if (auto *lvt = dyn_cast<LValueType>(desugar2)) {
|
||||
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
|
||||
ConstraintKind::Bind, subflags,
|
||||
locator.withPathElement(
|
||||
ConstraintLocator::LValueConversion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kind >= ConstraintKind::Conversion) {
|
||||
// An lvalue of type T1 can be converted to a value of type T2 so long as
|
||||
// T1 is convertible to T2 (by loading the value). Note that we cannot get
|
||||
@@ -7777,7 +7793,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
}
|
||||
|
||||
// Special implicit nominal conversions.
|
||||
if (!type1->is<LValueType>() && kind >= ConstraintKind::Subtype) {
|
||||
if (!type1->is<LValueType>()) {
|
||||
// Array -> Array.
|
||||
if (desugar1->isArray() && desugar2->isArray()) {
|
||||
conversionsOrFixes.push_back(ConversionRestrictionKind::ArrayUpcast);
|
||||
@@ -7793,11 +7809,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
}
|
||||
}
|
||||
|
||||
if (kind == ConstraintKind::BindToPointerType) {
|
||||
if (desugar2->isEqual(getASTContext().TheEmptyTupleType))
|
||||
return getTypeMatchSuccess();
|
||||
}
|
||||
|
||||
if (kind >= ConstraintKind::Conversion) {
|
||||
// It is never legal to form an autoclosure that results in these
|
||||
// implicit conversions to pointer types.
|
||||
@@ -8054,17 +8065,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
}
|
||||
}
|
||||
|
||||
if (kind == ConstraintKind::BindParam) {
|
||||
if (auto *iot = dyn_cast<InOutType>(desugar1)) {
|
||||
if (auto *lvt = dyn_cast<LValueType>(desugar2)) {
|
||||
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
|
||||
ConstraintKind::Bind, subflags,
|
||||
locator.withPathElement(
|
||||
ConstraintLocator::LValueConversion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Matching types where one side is a pack expansion and the other is not
|
||||
// means a pack expansion was used where it isn't supported.
|
||||
if (type1->is<PackExpansionType>() != type2->is<PackExpansionType>()) {
|
||||
|
||||
Reference in New Issue
Block a user