Move opposite_variance to type utils
This commit is contained in:
parent
fbf12cf8b4
commit
dab0e4b758
@ -124,6 +124,10 @@ unify(A, B, C, D) -> aeso_tc_unify:unify(A, B, C, D).
|
||||
unfold_types_in_type(A, B) -> aeso_tc_type_unfolding:unfold_types_in_type(A, B).
|
||||
unfold_record_types(A, B) -> aeso_tc_type_unfolding:unfold_record_types(A, B).
|
||||
|
||||
%% -------
|
||||
|
||||
opposite_variance(A) -> aeso_tc_type_utils:opposite_variance(A).
|
||||
|
||||
%% -- The rest ---------------------------------------------------------------
|
||||
|
||||
map_t(As, K, V) -> {app_t, As, {id, As, "map"}, [K, V]}.
|
||||
@ -510,11 +514,6 @@ infer_type_vars_variance({fun_t, _, [], Args, Res}) ->
|
||||
FlippedArgsVariance ++ ResVariance;
|
||||
infer_type_vars_variance(_) -> [].
|
||||
|
||||
opposite_variance(invariant) -> invariant;
|
||||
opposite_variance(covariant) -> contravariant;
|
||||
opposite_variance(contravariant) -> covariant;
|
||||
opposite_variance(bivariant) -> bivariant.
|
||||
|
||||
-spec check_constants(env(), [aeso_syntax:decl()]) -> {env(), [aeso_syntax:decl()]}.
|
||||
check_constants(Env, Consts) ->
|
||||
HasValidId = fun({letval, _, {id, _, _}, _}) -> true;
|
||||
|
@ -7,6 +7,7 @@
|
||||
, fun_arity/1
|
||||
, ensure_first_order/2
|
||||
, ensure_monomorphic/2
|
||||
, opposite_variance/1
|
||||
]).
|
||||
|
||||
typesig_to_fun_t({type_sig, Ann, _Constr, Named, Args, Res}) ->
|
||||
@ -80,3 +81,8 @@ is_first_order({fun_t, _, _, _, _}) -> false;
|
||||
is_first_order(Ts) when is_list(Ts) -> lists:all(fun is_first_order/1, Ts);
|
||||
is_first_order(Tup) when is_tuple(Tup) -> is_first_order(tuple_to_list(Tup));
|
||||
is_first_order(_) -> true.
|
||||
|
||||
opposite_variance(invariant) -> invariant;
|
||||
opposite_variance(covariant) -> contravariant;
|
||||
opposite_variance(contravariant) -> covariant;
|
||||
opposite_variance(bivariant) -> bivariant.
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
-export([unify/4]).
|
||||
|
||||
%% -- Circular dependency ----------------------------------------------------
|
||||
|
||||
opposite_variance(A) -> aeso_ast_infer_types:opposite_variance(A).
|
||||
|
||||
%% -- Moved functions --------------------------------------------------------
|
||||
|
||||
@ -15,6 +12,10 @@ unfold_types_in_type(A, B, C) -> aeso_tc_type_unfolding:unfold_types_in_type(A,
|
||||
type_error(A) -> aeso_tc_errors:type_error(A).
|
||||
cannot_unify(A, B, C, D) -> aeso_tc_errors:cannot_unify(A, B, C, D).
|
||||
|
||||
%% -------
|
||||
|
||||
opposite_variance(A) -> aeso_tc_type_utils:opposite_variance(A).
|
||||
|
||||
%% ---------------------------------------------------------------------------
|
||||
|
||||
unify(Env, A, B, When) -> unify0(Env, A, B, covariant, When).
|
||||
|
Loading…
x
Reference in New Issue
Block a user