mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ConstraintSystem] Increase fix impact when get-only dynamic key path is used as a mutable one
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user