Skip to content

Commit 71a94a8

Browse files
author
Amritpan Kaur
committed
[CSSimplify] Add checks for invalid keypath member refs
1 parent 37b9a69 commit 71a94a8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10332,7 +10332,9 @@ static ConstraintFix *fixMemberRef(
1033210332
return fix;
1033310333
}
1033410334

10335-
if (locator->isForKeyPathDynamicMemberLookup()) {
10335+
if (locator->isForKeyPathDynamicMemberLookup() ||
10336+
locator->isForKeyPathComponent() ||
10337+
locator->isKeyPathSubscriptComponent()) {
1033610338
if (auto *fix = AllowInvalidRefInKeyPath::forRef(cs, decl, locator))
1033710339
return fix;
1033810340
}
@@ -12303,11 +12305,9 @@ ConstraintSystem::simplifyKeyPathConstraint(
1230312305

1230412306
auto storage = dyn_cast<AbstractStorageDecl>(choice.getDecl());
1230512307

12306-
if (auto *fix = AllowInvalidRefInKeyPath::forRef(
12307-
*this, choice.getDecl(), calleeLoc)) {
12308-
if (!hasFixFor(calleeLoc, FixKind::AllowTypeOrInstanceMember))
12309-
if (!shouldAttemptFixes() || recordFix(fix))
12310-
return SolutionKind::Error;
12308+
if (hasFixFor(calleeLoc, FixKind::AllowInvalidRefInKeyPath)) {
12309+
if (!shouldAttemptFixes())
12310+
return SolutionKind::Error;
1231112311

1231212312
// If this was a method reference let's mark it as read-only.
1231312313
if (!storage) {

0 commit comments

Comments
 (0)