@@ -6989,6 +6989,14 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
6989
6989
return formUnsolvedResult();
6990
6990
}
6991
6991
6992
+ // Closure result is allowed to convert to Void in certain circumstances,
6993
+ // let's forego tuple matching because it is guaranteed to fail and jump
6994
+ // to `() -> T` to `() -> Void` rule.
6995
+ if (locator.endsWith<LocatorPathElt::ClosureBody>()) {
6996
+ if (containsPackExpansionType(tuple1) && tuple2->isVoid())
6997
+ break;
6998
+ }
6999
+
6992
7000
// Add each tuple type to the locator before matching the element types.
6993
7001
// This is useful for diagnostics, because the error message can use the
6994
7002
// full tuple type for several element mismatches. Use the original types
@@ -7286,22 +7294,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
7286
7294
}
7287
7295
}
7288
7296
7289
- // Matching types where one side is a pack expansion and the other is not
7290
- // means a pack expansion was used where it isn't supported.
7291
- if (type1->is<PackExpansionType>() != type2->is<PackExpansionType>()) {
7292
- if (!shouldAttemptFixes())
7293
- return getTypeMatchFailure(locator);
7294
-
7295
- if (type1->isPlaceholder() || type2->isPlaceholder())
7296
- return getTypeMatchSuccess();
7297
-
7298
- auto *loc = getConstraintLocator(locator);
7299
- if (recordFix(AllowInvalidPackExpansion::create(*this, loc)))
7300
- return getTypeMatchFailure(locator);
7301
-
7302
- return getTypeMatchSuccess();
7303
- }
7304
-
7305
7297
if (kind >= ConstraintKind::Conversion) {
7306
7298
// An lvalue of type T1 can be converted to a value of type T2 so long as
7307
7299
// T1 is convertible to T2 (by loading the value). Note that we cannot get
@@ -7724,6 +7716,22 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
7724
7716
}
7725
7717
}
7726
7718
7719
+ // Matching types where one side is a pack expansion and the other is not
7720
+ // means a pack expansion was used where it isn't supported.
7721
+ if (type1->is<PackExpansionType>() != type2->is<PackExpansionType>()) {
7722
+ if (!shouldAttemptFixes())
7723
+ return getTypeMatchFailure(locator);
7724
+
7725
+ if (type1->isPlaceholder() || type2->isPlaceholder())
7726
+ return getTypeMatchSuccess();
7727
+
7728
+ auto *loc = getConstraintLocator(locator);
7729
+ if (recordFix(AllowInvalidPackExpansion::create(*this, loc)))
7730
+ return getTypeMatchFailure(locator);
7731
+
7732
+ return getTypeMatchSuccess();
7733
+ }
7734
+
7727
7735
// Attempt fixes iff it's allowed, both types are concrete and
7728
7736
// we are not in the middle of attempting one already.
7729
7737
if (shouldAttemptFixes() && !flags.contains(TMF_ApplyingFix)) {
0 commit comments