Merge pull request #23497 from theblixguy/fix/SR-10146

[CSApply] Fix a KeyPath crash in SIL when base type is AnyObject
This commit is contained in:
Joe Groff
2019-03-25 14:13:41 -07:00
committed by GitHub
2 changed files with 22 additions and 1 deletions

View File

@@ -4184,7 +4184,16 @@ namespace {
auto keyPathTy = cs.getType(E)->castTo<BoundGenericType>();
Type baseTy = keyPathTy->getGenericArgs()[0];
Type leafTy = keyPathTy->getGenericArgs()[1];
// We do not allow keypaths to go through AnyObject
if (baseTy->isAnyObject()) {
auto rootTyRepr = E->getRootType();
cs.TC.diagnose(rootTyRepr->getLoc(),
diag::expr_swift_keypath_invalid_component)
.highlight(rootTyRepr->getSourceRange());
return nullptr;
}
for (unsigned i : indices(E->getComponents())) {
auto &origComponent = E->getMutableComponents()[i];