Skip to content

Commit bfeade4

Browse files
committed
[CSSimplify] Cleanup some obsolete code from key path simplification
Since key path type is always bound by inference before the constraint could be simplified, there is no need to search for a contextual type or try to bind key path type if there are errors in the path.
1 parent 161e126 commit bfeade4

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12333,16 +12333,6 @@ ConstraintSystem::simplifyKeyPathConstraint(
1233312333
tv->getImpl().canBindToHole();
1233412334
})) {
1233512335
(void)tryMatchRootAndValueFromType(keyPathTy);
12336-
12337-
// If the type of the key path is not yet resolved simplifying this
12338-
// constraint would disconnect it from root and value, let's bind it
12339-
// to a placeholder type to make sure this doesn't happen.
12340-
if (auto *typeVar = keyPathTy->getAs<TypeVariableType>()) {
12341-
return matchTypes(keyPathTy, PlaceholderType::get(Context, typeVar),
12342-
ConstraintKind::Bind, subflags,
12343-
locator.getBaseLocator());
12344-
}
12345-
1234612336
return SolutionKind::Solved;
1234712337
}
1234812338
}
@@ -12353,12 +12343,6 @@ ConstraintSystem::simplifyKeyPathConstraint(
1235312343
if (!tryMatchRootAndValueFromType(keyPathTy, /*allowPartial=*/false))
1235412344
return SolutionKind::Error;
1235512345

12356-
// If the expression has contextual type information, try using that too.
12357-
if (auto contextualTy = getContextualType(keyPath, /*forConstraint=*/false)) {
12358-
if (!tryMatchRootAndValueFromType(contextualTy))
12359-
return SolutionKind::Error;
12360-
}
12361-
1236212346
// If we fix this keypath as `AllowMultiArgFuncKeyPathMismatch`, just proceed
1236312347
if (resolveAsMultiArgFuncFix)
1236412348
return SolutionKind::Solved;
@@ -12422,14 +12406,8 @@ ConstraintSystem::simplifyKeyPathConstraint(
1242212406
auto storage = dyn_cast<AbstractStorageDecl>(choice.getDecl());
1242312407

1242412408
if (hasFixFor(calleeLoc, FixKind::AllowInvalidRefInKeyPath)) {
12425-
if (!shouldAttemptFixes())
12426-
return SolutionKind::Error;
12427-
12428-
// If this was a method reference let's mark it as read-only.
12429-
if (!storage) {
12430-
capability = ReadOnly;
12431-
continue;
12432-
}
12409+
return shouldAttemptFixes() ? SolutionKind::Solved
12410+
: SolutionKind::Error;
1243312411
}
1243412412

1243512413
if (!storage)

0 commit comments

Comments
 (0)