Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize annotated types #228

Merged
merged 2 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/typechecker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ normalize({type, _, union, Tys}, TEnv) ->
[T] -> T;
Ts -> type(union, Ts)
end;
normalize({ann_type, _Ann, [_Var, Type]}, TEnv) ->
normalize(Type, TEnv);
normalize({user_type, P, Name, Args} = Type, TEnv) ->
case typelib:get_module_from_annotation(P) of
{ok, Module} ->
Expand Down
9 changes: 0 additions & 9 deletions test/known_problems/should_pass/annotated_types_problems.erl

This file was deleted.

13 changes: 0 additions & 13 deletions test/known_problems/should_pass/pattern_ann_type.erl

This file was deleted.

17 changes: 16 additions & 1 deletion test/should_pass/ann_types.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%% @doc Test module for annotated types
-module(ann_types).

-export([f/2]).
-export([f/2, g/2, h/1, annotated_named_record_arg/1, remote_named_record_arg/1]).

-spec f(A :: atom(), integer()) -> {A :: term(), B :: number()}.
f(A, B) ->
Expand All @@ -10,3 +10,18 @@ f(A, B) ->
-spec g(A :: atom(), Map :: map()) -> NewMap :: map().
g(A, Map) ->
Map#{ A => any }.

-type mytuple() :: tuple().
-spec h(Pat :: mytuple()) -> ok.
h({}) ->
ok.

-record(r, {}).
-type r() :: #r{}.
-spec annotated_named_record_arg(R :: r()) -> {ok, R :: r()}.
annotated_named_record_arg(#r{} = R) -> {ok, R}.

-spec remote_named_record_arg(R :: user_types:my_empty_record()) ->
{ok, R :: user_types:my_empty_record()}.
remote_named_record_arg(#r{} = R) -> {ok, R}.

4 changes: 3 additions & 1 deletion test/should_pass/user_types.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
-export([f/1]).

%% these exported types are used in remote_types module
-export_type([my_tuple/0, my_list/0, my_union/0, my_opaque/0]).
-export_type([my_tuple/0, my_list/0, my_union/0, my_opaque/0, my_empty_record/0]).

-record(r, {}).
-type my_empty_record() :: #r{}.
-type my_atom() :: atom().
-type my_tuple() :: {my_atom(), integer()}.
-type my_list() :: list(my_atom()).
Expand Down