aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2015-11-05 17:09:09 +0100
committerHans Bolinder <[email protected]>2015-12-07 09:41:25 +0100
commit0ad8b47ce2ec578eab64896a3ba8af3f71ce2fd1 (patch)
tree0c78d10e233c52545a84795724d2b88313084106 /lib
parent4b5cc477a78247dd68f142d5cb044ff0c34a576b (diff)
downloadotp-0ad8b47ce2ec578eab64896a3ba8af3f71ce2fd1.tar.gz
otp-0ad8b47ce2ec578eab64896a3ba8af3f71ce2fd1.tar.bz2
otp-0ad8b47ce2ec578eab64896a3ba8af3f71ce2fd1.zip
stdlib: Pretty-print constraints as 'V :: T'
Print constraints as 'V :: T' rather than 'is_subtype(V, T)'.
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/src/erl_pp.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl
index f7a969977a..9c812395e3 100644
--- a/lib/stdlib/src/erl_pp.erl
+++ b/lib/stdlib/src/erl_pp.erl
@@ -253,6 +253,8 @@ lattribute(import, Name, _Opts, _State) when is_list(Name) ->
attr("import", [{var,a0(),pname(Name)}]);
lattribute(import, {From,Falist}, _Opts, _State) ->
attr("import",[{var,a0(),pname(From)},falist(Falist)]);
+lattribute(export_type, Talist, _Opts, _State) ->
+ call({var,a0(),"-export_type"}, [falist(Talist)], 0, options(none));
lattribute(optional_callbacks, Falist, Opts, _State) ->
ArgL = try falist(Falist)
catch _:_ -> abstract(Falist, Opts)
@@ -321,7 +323,6 @@ ltype({type,_,'fun',[{type,_,any},_]}=FunType, _) ->
ltype({type,_Line,'fun',[{type,_,product,_},_]}=FunType, _) ->
[fun_type(['fun',$(], FunType),$)];
ltype({type,Line,T,Ts}, _) ->
- %% Compatibility. Before 18.0.
simple_type({atom,Line,T}, Ts);
ltype({user_type,Line,T,Ts}, _) ->
simple_type({atom,Line,T}, Ts);
@@ -399,6 +400,9 @@ guard_type(Before, Gs) ->
Gl = {list,[{step,'when',expr_list(Gs, [$,], fun constraint/2, Opts)}]},
{list,[{step,Before,Gl}]}.
+constraint({type,_Line,constraint,[{atom,_,is_subtype},[{var,_,_}=V,Type]]},
+ _Opts) ->
+ typed(lexpr(V, options(none)), Type);
constraint({type,_Line,constraint,[Tag,As]}, _Opts) ->
simple_type(Tag, As).