Skip to content

Commit aac8000

Browse files
committed
Use lists:usort/1 instead of lists:uniq/1 on OTP < 25
lists:uniq/1 was introduced in OTP 25.
1 parent 8efca04 commit aac8000

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/constraints.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ do_combine(Cs1, Cs2, Env) ->
6565

6666
-spec variables(t()) -> [var()].
6767
variables(#constraints{ upper_bounds = UBounds, lower_bounds = LBounds }) ->
68-
lists:uniq(maps:keys(UBounds) ++ maps:keys(LBounds)).
68+
gradualizer_lib:uniq(maps:keys(UBounds) ++ maps:keys(LBounds)).
6969

7070

7171
%% Checks that all lower bounds are subtypes of respective upper bounds.

src/gradualizer_lib.erl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%% @private
22
-module(gradualizer_lib).
33

4-
-export([merge_with/3, top_sort/1, get_type_definition/3,
4+
-export([merge_with/3, uniq/1, top_sort/1, get_type_definition/3,
55
pick_values/2, fold_ast/3, get_ast_children/1,
66
empty_tenv/0, create_tenv/3,
77
remove_pos_typed_record_field/1,
@@ -45,6 +45,13 @@ merge_with(F, M1, M2) ->
4545
end.
4646
-endif.
4747

48+
-spec uniq([A]) -> [A].
49+
-if(?OTP_RELEASE >= 25).
50+
uniq(List) -> lists:uniq(List).
51+
-else.
52+
uniq(List) -> lists:usort(List).
53+
-endif.
54+
4855
%% -- Topological sort
4956

5057
-type graph(Node) :: #{Node => [Node]}. %% List of incoming edges (dependencies).

0 commit comments

Comments
 (0)