From e24ac29bd6b0a312357a25f9038088f5b8ea5b77 Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 16 Feb 2024 21:02:15 +0100 Subject: [PATCH] Fix Dialyzer by copying some type specs that Jiffy doesn't export Since Erlang/OTP 26.0, Dialyzer enables by default "unknown" types warnings https://www.erlang.org/patches/otp-26.0 --- include/mod_matrix_gw.hrl | 16 ++++++++++++++++ src/mod_matrix_gw.erl | 2 +- src/mod_matrix_gw_room.erl | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/mod_matrix_gw.hrl b/include/mod_matrix_gw.hrl index 7ebaa085437..93a4c485db6 100644 --- a/include/mod_matrix_gw.hrl +++ b/include/mod_matrix_gw.hrl @@ -26,3 +26,19 @@ implicit_room_creator :: boolean(), updated_redaction_rules :: boolean() }). + +%% Jiffy doesn't export those type specs, so they are copied here from +%% https://github.com/davisp/jiffy/blob/master/src/jiffy.erl + +-type json_value() :: null + | true + | false + | json_string() + | json_number() + | json_object() + | json_array(). +-type json_array() :: [json_value()]. +-type json_string() :: atom() | binary(). +-type json_number() :: integer() | float(). +-type json_object() :: {[{json_string(),json_value()}]} + | #{json_string() => json_value()}. diff --git a/src/mod_matrix_gw.erl b/src/mod_matrix_gw.erl index 5981f97ca84..0214229551f 100644 --- a/src/mod_matrix_gw.erl +++ b/src/mod_matrix_gw.erl @@ -736,7 +736,7 @@ sign_json(Host, JSON) -> binary(), [binary()], [{binary(), binary()}], - none | jiffy:json_object(), + none | json_object(), [any()], [any()]) -> {ok, any()} | {error, any()}. diff --git a/src/mod_matrix_gw_room.erl b/src/mod_matrix_gw_room.erl index e4d3489162e..b0db41abfd1 100644 --- a/src/mod_matrix_gw_room.erl +++ b/src/mod_matrix_gw_room.erl @@ -67,7 +67,7 @@ sender :: binary(), prev_events :: [binary()], origin_server_ts :: integer(), - json :: jiffy:json_object(), + json :: json_object(), state_map}). -record(data,