mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user