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:
@@ -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