Skip to content

Commit

Permalink
Disable opaque_union Dialyzer warnings introduced in Erlang/OTP 28
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed Jan 24, 2025
1 parent efa401b commit e6e03db
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ defmodule Ejabberd.MixProject do
if_version_below(~c"25", [{:d, :OTP_BELOW_25}]) ++
if_version_below(~c"26", [{:d, :OTP_BELOW_26}]) ++
if_version_below(~c"27", [{:d, :OTP_BELOW_27}]) ++
if_type_exported(:odbc, {:opaque, :connection_reference, 0}, [{:d, :ODBC_HAS_TYPES}])
if_version_below(~c"28", [{:d, :OTP_BELOW_28}])
defines = for {:d, value} <- result, do: {:d, value}
result ++ [{:d, :ALL_DEFS, defines}]
end
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@
{if_version_below, "25", {d, 'OTP_BELOW_25'}},
{if_version_below, "26", {d, 'OTP_BELOW_26'}},
{if_version_below, "27", {d, 'OTP_BELOW_27'}},
{if_version_below, "28", {d, 'OTP_BELOW_28'}},
{if_var_false, debug, no_debug_info},
{if_var_true, debug, debug_info},
{if_var_true, elixir, {d, 'ELIXIR_ENABLED'}},
{if_var_true, new_sql_schema, {d, 'NEW_SQL_SCHEMA'}},
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATEWAY_WORKAROUND'}},
{if_var_true, sip, {d, 'SIP'}},
{if_var_true, stun, {d, 'STUN'}},
{if_type_exported, {odbc, {opaque, connection_reference, 0}}, {d, 'ODBC_HAS_TYPES'}},
{src_dirs, [src,
{if_rebar3, sql},
{if_var_true, tools, tools}]}]}.
Expand Down
4 changes: 4 additions & 0 deletions src/ejabberd_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@

-optional_callbacks([globals/0]).

-ifndef(OTP_BELOW_28).
-dialyzer([no_opaque_union]).
-endif.

%%%===================================================================
%%% API
%%%===================================================================
Expand Down
4 changes: 4 additions & 0 deletions src/ejabberd_shaper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@

-export_type([shaper/0, shaper_rule/0, shaper_rate/0]).

-ifndef(OTP_BELOW_28).
-dialyzer([no_opaque_union]).
-endif.

%%%===================================================================
%%% API
%%%===================================================================
Expand Down
19 changes: 15 additions & 4 deletions src/ejabberd_sql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,29 @@
-export([connecting/2, connecting/3,
session_established/2, session_established/3]).

-ifdef(ODBC_HAS_TYPES).
-type(odbc_connection_reference() :: odbc:connection_reference()).
-ifdef(OTP_BELOW_28).
-ifdef(OTP_BELOW_27).
%% OTP 26 or lower
-type(odbc_connection_reference() :: odbc:connection_reference()).
-type(db_ref_pid() :: pid()).
-else.
-type(odbc_connection_reference() :: pid()).
%% OTP 27
-type(odbc_connection_reference() :: pid()).
-type(db_ref_pid() :: pid()).
-endif.
-else.
%% OTP 28 or higher
-nominal(odbc_connection_reference() :: odbc:connection_reference()).
-nominal(db_ref_pid() :: pid()).
-dialyzer([no_opaque_union]).
-endif.

-include("logger.hrl").
-include("ejabberd_sql_pt.hrl").
-include("ejabberd_stacktrace.hrl").

-record(state,
{db_ref :: undefined | pid() | odbc_connection_reference(),
{db_ref :: undefined | db_ref_pid() | odbc_connection_reference(),
db_type = odbc :: pgsql | mysql | sqlite | odbc | mssql,
db_version :: undefined | non_neg_integer() | {non_neg_integer(), atom(), non_neg_integer()},
reconnect_count = 0 :: non_neg_integer(),
Expand Down
5 changes: 5 additions & 0 deletions src/ejabberd_websocket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
?AC_ALLOW_HEADERS, ?AC_MAX_AGE]).
-define(HEADER, [?CT_XML, ?AC_ALLOW_ORIGIN, ?AC_ALLOW_HEADERS]).

-ifndef(OTP_BELOW_28).
-dialyzer([no_opaque_union]).
-endif.


is_valid_websocket_upgrade(_Path, Headers) ->
HeadersToValidate = [{'Upgrade', <<"websocket">>},
{'Connection', ignore},
Expand Down
4 changes: 4 additions & 0 deletions src/mod_muc_room.erl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
-callback search_affiliation(binary(), binary(), binary(), affiliation()) ->
{ok, [{ljid(), {affiliation(), binary()}}]} | {error, any()}.

-ifndef(OTP_BELOW_28).
-dialyzer([no_opaque_union]).
-endif.

%%%----------------------------------------------------------------------
%%% API
%%%----------------------------------------------------------------------
Expand Down

0 comments on commit e6e03db

Please sign in to comment.