mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSSimplify] Allow converting tuple with pack expansions to Void for closure result
Maintains existing rule where single-expression closure is allowed to convert to contextual function type with `Void` result.
This commit is contained in:
committed by
Pavel Yaskevich
parent
effa261266
commit
dc4ee4b61a
@@ -6985,6 +6985,14 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
return formUnsolvedResult();
|
||||
}
|
||||
|
||||
// Closure result is allowed to convert to Void in certain circumstances,
|
||||
// let's forego tuple matching because it is guaranteed to fail and jump
|
||||
// to `() -> T` to `() -> Void` rule.
|
||||
if (locator.endsWith<LocatorPathElt::ClosureBody>()) {
|
||||
if (containsPackExpansionType(tuple1) && tuple2->isVoid())
|
||||
break;
|
||||
}
|
||||
|
||||
// Add each tuple type to the locator before matching the element types.
|
||||
// This is useful for diagnostics, because the error message can use the
|
||||
// full tuple type for several element mismatches. Use the original types
|
||||
|
||||
Reference in New Issue
Block a user