Skip to content

Commit 157c118

Browse files
committed
Refine Dialyzer fix for get/2 in mod_presence
The previous patch silenced the opaque-jid warning by falling back to `term()`. Replace that quick fix with a single merged type-spec that covers all keys. This way Dialyzer no longer flags the jid opacity, and we avoid using `term()`.
1 parent fa35695 commit 157c118

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/mod_presence.erl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
-type priority() :: -128..127.
2020
-type maybe_priority() :: priority() | undefined.
2121

22-
-type jid_set() :: term().
2322
-type available() :: sets:set(jid:jid()).
2423
-type subscription() :: from | to | both.
2524
-type subscriptions() :: #{jid:jid() := subscription()}.
@@ -691,12 +690,8 @@ get_by_sub(#presences_state{subscriptions = Subs}, DesiredStatus) ->
691690
Filter = fun(_, Status) -> both =:= Status orelse DesiredStatus =:= Status end,
692691
maps:filter(Filter, Subs).
693692

694-
-spec get(state(), s_to) -> subscriptions();
695-
(state(), s_from) -> subscriptions();
696-
(state(), s_available) -> jid_set();
697-
(state(), priority) -> priority();
698-
(state(), last) -> undefined | exml:element();
699-
(state(), timestamp) -> undefined | integer().
693+
-spec get(state(), s_to | s_from | s_available | priority | last | timestamp) ->
694+
subscriptions() | available() | priority() | exml:element() | integer() | undefined.
700695
get(P, s_to) -> get_by_sub(P, to);
701696
get(P, s_from) -> get_by_sub(P, from);
702697
get(#presences_state{available = Value}, s_available) -> Value;

0 commit comments

Comments
 (0)