aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/dialyzer/src/dialyzer_behaviours.erl15
-rw-r--r--lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl2
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/dialyzer/src/dialyzer_behaviours.erl b/lib/dialyzer/src/dialyzer_behaviours.erl
index b478af01df..82963783d8 100644
--- a/lib/dialyzer/src/dialyzer_behaviours.erl
+++ b/lib/dialyzer/src/dialyzer_behaviours.erl
@@ -110,11 +110,16 @@ check_all_callbacks(Module, Behaviour, [Cb|Rest], Plt, Acc) ->
Acc00 = Acc0,
{ReturnType, ArgTypes} = RetArgTypes,
Acc01 =
- case erl_types:t_is_none(erl_types:t_inf(ReturnType, CbReturnType)) of
- false -> Acc00;
- true ->
- [{callback_type_mismatch,[Behaviour, Function,
- Arity, ReturnType]}|Acc00]
+ case erl_types:t_is_subtype(ReturnType, CbReturnType) of
+ true -> Acc00;
+ false ->
+ case erl_types:t_is_none(
+ erl_types:t_inf(ReturnType, CbReturnType)) of
+ false -> Acc00;
+ true ->
+ [{callback_type_mismatch,[Behaviour, Function,
+ Arity, ReturnType]}|Acc00]
+ end
end,
Acc02 =
case erl_types:any_none(
diff --git a/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl b/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl
index 148cea6843..c218174e58 100644
--- a/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl
+++ b/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl
@@ -13,7 +13,7 @@
]).
sample_callback_1() -> 42. % This is a valid return.
-sample_callback_2() -> foo. % This is a valid return.
+sample_callback_2() -> halt(). % Crashes are also allowed.
sample_callback_3() -> {ok, 17}. % This is a valid return.
sample_callback_4(Input) ->
case Input of