[ConstraintSystem] Increase fix impact when get-only dynamic key path is used as a mutable one

This commit is contained in:
Pavel Yaskevich
2020-02-21 17:28:10 -08:00
parent 0a6b444b49
commit ed255596a6
2 changed files with 3 additions and 5 deletions

View File

@@ -9103,7 +9103,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
// subscript, which requires changes to declaration to become mutable.
if (auto last = locator.last()) {
impact += (last->is<LocatorPathElt::FunctionResult>() ||
last->is<LocatorPathElt::SubscriptMember>())
last->is<LocatorPathElt::SubscriptMember>() ||
last->is<LocatorPathElt::KeyPathDynamicMember>())
? 1
: 0;
}

View File

@@ -600,10 +600,7 @@ func keypath_with_subscripts(_ arr: SubscriptLens<[Int]>,
func keypath_with_incorrect_return_type(_ arr: Lens<Array<Int>>) {
for idx in 0..<arr.count {
// expected-error@-1 {{protocol 'Sequence' requires that 'Lens<Int>' conform to 'Strideable'}}
// expected-error@-2 {{protocol 'Sequence' requires that 'Lens<Int>.Stride' conform to 'SignedInteger'}}
// expected-error@-3 {{cannot convert value of type 'Int' to expected argument type 'Lens<Int>'}}
// expected-error@-4 {{referencing operator function '..<' on 'Comparable' requires that 'Lens<Int>' conform to 'Comparable'}}
// expected-error@-1 {{cannot convert value of type 'Lens<Int>' to expected argument type 'Int'}}
let _ = arr[idx]
}
}