Skip to content

Commit c47ff06

Browse files
committed
Sema: Tiny cleanup for matchTypes()
1 parent 5ee97c5 commit c47ff06

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4608,16 +4608,15 @@ class ConstraintSystem {
46084608
inline bool isFailure() const { return Kind == SolutionKind::Error; }
46094609
inline bool isAmbiguous() const { return Kind == SolutionKind::Unsolved; }
46104610

4611-
static TypeMatchResult success(ConstraintSystem &cs) {
4611+
static TypeMatchResult success() {
46124612
return {SolutionKind::Solved};
46134613
}
46144614

4615-
static TypeMatchResult failure(ConstraintSystem &cs,
4616-
ConstraintLocatorBuilder location) {
4615+
static TypeMatchResult failure() {
46174616
return {SolutionKind::Error};
46184617
}
46194618

4620-
static TypeMatchResult ambiguous(ConstraintSystem &cs) {
4619+
static TypeMatchResult ambiguous() {
46214620
return {SolutionKind::Unsolved};
46224621
}
46234622

@@ -4722,15 +4721,15 @@ class ConstraintSystem {
47224721
ConstraintLocatorBuilder locator);
47234722

47244723
TypeMatchResult getTypeMatchSuccess() {
4725-
return TypeMatchResult::success(*this);
4724+
return TypeMatchResult::success();
47264725
}
47274726

47284727
TypeMatchResult getTypeMatchFailure(ConstraintLocatorBuilder locator) {
4729-
return TypeMatchResult::failure(*this, locator);
4728+
return TypeMatchResult::failure();
47304729
}
47314730

47324731
TypeMatchResult getTypeMatchAmbiguous() {
4733-
return TypeMatchResult::ambiguous(*this);
4732+
return TypeMatchResult::ambiguous();
47344733
}
47354734

47364735
public:

lib/Sema/CSSimplify.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7646,6 +7646,22 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
76467646
}
76477647
}
76487648

7649+
if (kind == ConstraintKind::BindToPointerType) {
7650+
if (desugar2->isEqual(getASTContext().TheEmptyTupleType))
7651+
return getTypeMatchSuccess();
7652+
}
7653+
7654+
if (kind == ConstraintKind::BindParam) {
7655+
if (auto *iot = dyn_cast<InOutType>(desugar1)) {
7656+
if (auto *lvt = dyn_cast<LValueType>(desugar2)) {
7657+
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
7658+
ConstraintKind::Bind, subflags,
7659+
locator.withPathElement(
7660+
ConstraintLocator::LValueConversion));
7661+
}
7662+
}
7663+
}
7664+
76497665
if (kind >= ConstraintKind::Conversion) {
76507666
// An lvalue of type T1 can be converted to a value of type T2 so long as
76517667
// 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,
77777793
}
77787794

77797795
// Special implicit nominal conversions.
7780-
if (!type1->is<LValueType>() && kind >= ConstraintKind::Subtype) {
7796+
if (!type1->is<LValueType>()) {
77817797
// Array -> Array.
77827798
if (desugar1->isArray() && desugar2->isArray()) {
77837799
conversionsOrFixes.push_back(ConversionRestrictionKind::ArrayUpcast);
@@ -7793,11 +7809,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
77937809
}
77947810
}
77957811

7796-
if (kind == ConstraintKind::BindToPointerType) {
7797-
if (desugar2->isEqual(getASTContext().TheEmptyTupleType))
7798-
return getTypeMatchSuccess();
7799-
}
7800-
78017812
if (kind >= ConstraintKind::Conversion) {
78027813
// It is never legal to form an autoclosure that results in these
78037814
// implicit conversions to pointer types.
@@ -8054,17 +8065,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
80548065
}
80558066
}
80568067

8057-
if (kind == ConstraintKind::BindParam) {
8058-
if (auto *iot = dyn_cast<InOutType>(desugar1)) {
8059-
if (auto *lvt = dyn_cast<LValueType>(desugar2)) {
8060-
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
8061-
ConstraintKind::Bind, subflags,
8062-
locator.withPathElement(
8063-
ConstraintLocator::LValueConversion));
8064-
}
8065-
}
8066-
}
8067-
80688068
// Matching types where one side is a pack expansion and the other is not
80698069
// means a pack expansion was used where it isn't supported.
80708070
if (type1->is<PackExpansionType>() != type2->is<PackExpansionType>()) {

0 commit comments

Comments
 (0)