mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When ranking constraint solutions, consider anything that causes
a function conversion to be bad. This encourages the type-checker to place conversions within closures rather than outside; the test case here crashed in SIL verification because of that. (Yes, that means that there's an underlying problem still when the function conversion is required; that's tracked by rdar://15875305.) But in general, function conversions are likely to be expensive, and it's good to avoid them when possible. The setup work to add SK_FunctionConversion was accidentally committed as part of r12813. Swift SVN r12839
This commit is contained in:
@@ -946,6 +946,14 @@ commit_to_conversions:
|
||||
return SolutionKind::Error;
|
||||
}
|
||||
|
||||
// Okay, we need to perform one or more conversions. If this
|
||||
// conversion will cause a function conversion, score it as worse.
|
||||
// This induces conversions to occur within closures instead of
|
||||
// outside of them wherever possible.
|
||||
if (locator.isFunctionConversion()) {
|
||||
increaseScore(SK_FunctionConversion);
|
||||
}
|
||||
|
||||
// Where there is more than one potential conversion, create a disjunction
|
||||
// so that we'll explore all of the options.
|
||||
if (potentialConversions.size() > 1) {
|
||||
|
||||
Reference in New Issue
Block a user