Swift: fix KeyPathExpr assertion

This commit is contained in:
Paolo Tranquilli
2025-02-05 10:41:59 +01:00
committed by Paolo Tranquilli
parent bcec7ee234
commit 1a654557a9

View File

@@ -379,12 +379,7 @@ codeql::KeyPathExpr ExprTranslator::translateKeyPathExpr(const swift::KeyPathExp
entry.components.push_back(emitKeyPathComponent(component));
}
if (auto rootTypeRepr = expr.getExplicitRootType()) {
auto keyPathType = expr.getType()->getAs<swift::BoundGenericClassType>();
CODEQL_EXPECT_OR(return entry, keyPathType, "KeyPathExpr must have BoundGenericClassType");
auto keyPathTypeArgs = keyPathType->getGenericArgs();
CODEQL_EXPECT_OR(return entry, keyPathTypeArgs.size() != 0,
"KeyPathExpr type must have generic args");
entry.root = dispatcher.fetchLabel(rootTypeRepr, keyPathTypeArgs[0]);
entry.root = dispatcher.fetchLabel(rootTypeRepr, expr.getRootType());
}
}
return entry;