-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add opaque state as a type declaration
- Loading branch information
Showing
7 changed files
with
215 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
test/examples/fail_state_record_and_type_plus_export_used_types.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-module(fail_state_record_and_type_plus_export_used_types). | ||
|
||
-dialyzer(no_behaviours). | ||
|
||
-behaviour(gen_server). | ||
|
||
-export([ | ||
init/1, | ||
handle_call/3, | ||
handle_cast/2, | ||
handle_info/2, | ||
code_change/3, | ||
terminate/2 | ||
]). | ||
|
||
-record(state, {}). | ||
|
||
-type state() :: #state{}. | ||
|
||
-spec init(term()) -> state(). | ||
init(_Args) -> | ||
#state{}. | ||
|
||
-spec handle_call(term(), term(), term()) -> ok. | ||
handle_call(_Request, _From, _State) -> | ||
ok. | ||
|
||
-spec handle_cast(term(), term()) -> ok. | ||
handle_cast(_Request, _State) -> | ||
ok. | ||
|
||
-spec handle_info(term(), term()) -> ok. | ||
handle_info(_Info, _State) -> | ||
ok. | ||
|
||
-spec code_change(term(), term(), term()) -> term(). | ||
code_change(_OldVsn, State, _Extra) -> | ||
{ok, State}. | ||
|
||
-spec terminate(term(), term()) -> ok. | ||
terminate(_Reason, _State) -> | ||
ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-module(pass_state_record_and_type_opaque). | ||
|
||
-dialyzer(no_behaviours). | ||
|
||
-behaviour(gen_server). | ||
|
||
-export([ | ||
init/1, | ||
handle_call/3, | ||
handle_cast/2, | ||
handle_info/2, | ||
code_change/3, | ||
terminate/2 | ||
]). | ||
|
||
-export_type([state/0]). | ||
|
||
-record(state, {}). | ||
|
||
-opaque state() :: #state{}. | ||
|
||
-spec init(term()) -> state(). | ||
init(_Args) -> | ||
#state{}. | ||
|
||
-spec handle_call(term(), term(), term()) -> ok. | ||
handle_call(_Request, _From, _State) -> | ||
ok. | ||
|
||
-spec handle_cast(term(), term()) -> ok. | ||
handle_cast(_Request, _State) -> | ||
ok. | ||
|
||
-spec handle_info(term(), term()) -> ok. | ||
handle_info(_Info, _State) -> | ||
ok. | ||
|
||
-spec code_change(term(), term(), term()) -> term(). | ||
code_change(_OldVsn, State, _Extra) -> | ||
{ok, State}. | ||
|
||
-spec terminate(term(), term()) -> ok. | ||
terminate(_Reason, _State) -> | ||
ok. |
44 changes: 44 additions & 0 deletions
44
test/examples/pass_state_record_and_type_plus_export_used_types.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-module(pass_state_record_and_type_plus_export_used_types). | ||
|
||
-dialyzer(no_behaviours). | ||
|
||
-behaviour(gen_server). | ||
|
||
-export([ | ||
init/1, | ||
handle_call/3, | ||
handle_cast/2, | ||
handle_info/2, | ||
code_change/3, | ||
terminate/2 | ||
]). | ||
|
||
-export_type([state/0]). | ||
|
||
-record(state, {}). | ||
|
||
-opaque state() :: #state{}. | ||
|
||
-spec init(term()) -> state(). | ||
init(_Args) -> | ||
#state{}. | ||
|
||
-spec handle_call(term(), term(), term()) -> ok. | ||
handle_call(_Request, _From, _State) -> | ||
ok. | ||
|
||
-spec handle_cast(term(), term()) -> ok. | ||
handle_cast(_Request, _State) -> | ||
ok. | ||
|
||
-spec handle_info(term(), term()) -> ok. | ||
handle_info(_Info, _State) -> | ||
ok. | ||
|
||
-spec code_change(term(), term(), term()) -> term(). | ||
code_change(_OldVsn, State, _Extra) -> | ||
{ok, State}. | ||
|
||
-spec terminate(term(), term()) -> ok. | ||
terminate(_Reason, _State) -> | ||
ok. |
29 changes: 29 additions & 0 deletions
29
test/examples/pass_state_record_and_type_plus_export_used_types_gen_statem.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-module(pass_state_record_and_type_plus_export_used_types_gen_statem). | ||
|
||
-dialyzer(no_behaviours). | ||
|
||
-behaviour(gen_statem). | ||
|
||
-export([ | ||
init/1, | ||
handle_event/4, | ||
callback_mode/0 | ||
]). | ||
|
||
-export_type([state/0]). | ||
|
||
-record(state, {}). | ||
|
||
-opaque state() :: #state{}. | ||
|
||
-spec init(term()) -> state(). | ||
init(_Args) -> | ||
#state{}. | ||
|
||
-spec handle_event(term(), term(), state(), term()) -> {next_state, state(), term()}. | ||
handle_event(_EventType, _EventContent, State, Data) -> | ||
{next_state, State, Data}. | ||
|
||
-spec callback_mode() -> handle_event_function. | ||
callback_mode() -> | ||
handle_event_function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters