Skip to content

Commit 7301bc7

Browse files
committed
Swift: Fix key path numbering in upgrade and downgrade scripts
1 parent 92ca0c2 commit 7301bc7

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

swift/downgrades/b7006eaacb007a06251596835506185619b86e98/key_path_components.ql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ class ValueDeclOrNone extends @value_decl_or_none {
1919
}
2020

2121
predicate isKeyPathComponentWithNewKind(KeyPathComponent id) {
22-
key_path_components(id, 3, _) or key_path_components(id, 4, _)
22+
key_path_components(id, 1, _) or key_path_components(id, 4, _)
2323
}
2424

2525
query predicate new_key_path_components(KeyPathComponent id, int kind, TypeOrNone component_type) {
2626
exists(int old_kind |
2727
key_path_components(id, old_kind, component_type) and
2828
not isKeyPathComponentWithNewKind(id) and
29-
if old_kind < 5 then kind = old_kind else kind = old_kind - 2
29+
if old_kind = 0
30+
then kind = old_kind
31+
else
32+
if old_kind = 2 or old_kind = 3
33+
then kind = old_kind - 1
34+
else kind = old_kind - 2
3035
)
3136
}
3237

swift/ql/lib/upgrades/987ab0bc0911f8c88449210e21d2ee80ebcb488a/key_path_components.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ class TypeOrNone extends @type_or_none {
99
from KeyPathComponent id, int kind, int new_kind, TypeOrNone component_type
1010
where
1111
key_path_components(id, kind, component_type) and
12-
if kind < 3 then new_kind = kind else new_kind = kind + 2
12+
if kind = 0
13+
then new_kind = kind
14+
else
15+
if kind = 1 or kind = 2
16+
then new_kind = kind + 1
17+
else new_kind = kind + 2
1318
select id, new_kind, component_type

0 commit comments

Comments
 (0)