Skip to content

Commit ed25559

Browse files
committed
[ConstraintSystem] Increase fix impact when get-only dynamic key path is used as a mutable one
1 parent 0a6b444 commit ed25559

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9103,7 +9103,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
91039103
// subscript, which requires changes to declaration to become mutable.
91049104
if (auto last = locator.last()) {
91059105
impact += (last->is<LocatorPathElt::FunctionResult>() ||
9106-
last->is<LocatorPathElt::SubscriptMember>())
9106+
last->is<LocatorPathElt::SubscriptMember>() ||
9107+
last->is<LocatorPathElt::KeyPathDynamicMember>())
91079108
? 1
91089109
: 0;
91099110
}

test/attr/attr_dynamic_member_lookup.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,7 @@ func keypath_with_subscripts(_ arr: SubscriptLens<[Int]>,
600600

601601
func keypath_with_incorrect_return_type(_ arr: Lens<Array<Int>>) {
602602
for idx in 0..<arr.count {
603-
// expected-error@-1 {{protocol 'Sequence' requires that 'Lens<Int>' conform to 'Strideable'}}
604-
// expected-error@-2 {{protocol 'Sequence' requires that 'Lens<Int>.Stride' conform to 'SignedInteger'}}
605-
// expected-error@-3 {{cannot convert value of type 'Int' to expected argument type 'Lens<Int>'}}
606-
// expected-error@-4 {{referencing operator function '..<' on 'Comparable' requires that 'Lens<Int>' conform to 'Comparable'}}
603+
// expected-error@-1 {{cannot convert value of type 'Lens<Int>' to expected argument type 'Int'}}
607604
let _ = arr[idx]
608605
}
609606
}

0 commit comments

Comments
 (0)