Swift: add comment about unique in getImmediateParent

This commit is contained in:
Paolo Tranquilli
2022-05-31 18:28:08 +02:00
parent bc0a32c26e
commit a4f97dd67a
2 changed files with 4 additions and 0 deletions

View File

@@ -41,5 +41,7 @@ Element getAnImmediateChild(Element e) {
* if `e` has conversions, `getImmediateParent(e)` will give the bottom conversion in the hidden AST.
*/
Element getImmediateParent(Element e) {
// `unique` is used here to tell the optimizer that there is in fact only one result
// this is tested by the `library-tests/parent/no_double_parents.ql` test
result = unique(Element x | e = getAnImmediateChild(x) | x)
}

View File

@@ -238,5 +238,7 @@ Element getAnImmediateChild(Element e) {
* if `e` has conversions, `getImmediateParent(e)` will give the bottom conversion in the hidden AST.
*/
Element getImmediateParent(Element e) {
// `unique` is used here to tell the optimizer that there is in fact only one result
// this is tested by the `library-tests/parent/no_double_parents.ql` test
result = unique(Element x | e = getAnImmediateChild(x) | x)
}