aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/opaque_SUITE_data/src/union/union_adt.erl
blob: d88f2381905dd4013e1b05b14177e12cc2a9101a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-module(union_adt).
-export([new/1, new_a/1, new_rec/1]).

%% Now (R17) that opaque types are no longer recognized by their shape
%% this test case is rather meaningless.

-record(rec, {x = 42 :: integer()}).

-opaque u() :: 'aaa' | 'bbb' | #rec{}.

-spec new(_) -> u().

new(a) -> aaa;
new(b) -> bbb;
new(X) when is_integer(X) ->
  #rec{x = X}.

%% the following two functions (and their uses in union_use.erl) test
%% that the return type is the opaque one and not just a subtype of it

-spec new_a(_) -> u().

new_a(a) -> aaa.

-spec new_rec(_) -> u().

new_rec(X) when is_integer(X) ->
  #rec{x = X}.