aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/opaque_SUITE_data/src/para/para2.erl
blob: 4461ff291cf6a8fde2c07f1752c810e91ddba209 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
-module(para2).

-compile(export_all).

%% More parameterized opaque types

-export_type([strange/1]).

-export_type([c1/0, c2/0]).

-export_type([circ/1, circ/2]).

-opaque strange(A) :: {B, B, A}.

-spec t(strange(integer())) -> strange(atom()).

t({3, 4, 5}) ->
    {a, b, c}.

-opaque c1() :: c2().
-opaque c2() :: c1().

c() ->
    A = c1(),
    B = c2(),
    A =:= B.

t() ->
    A = ct1(),
    B = ct2(),
    A =:= B. % can never evaluate to 'true'

-spec c1() -> c1().

c1() ->
    a.

-spec c2() -> c2().

c2() ->
    a.

-type ct1() :: ct2().
-type ct2() :: ct1().

-spec ct1() -> ct1().

ct1() ->
    a.

-spec ct2() -> ct2().

ct2() ->
    b.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

c_adt() ->
    A = c1_adt(),
    B = c2_adt(),
    A =:= B. % opaque attempt

t_adt() ->
    A = ct1_adt(),
    B = ct2_adt(),
    A =:= B. % can never evaluate to true

c1_adt() ->
    para2_adt:c1().

c2_adt() ->
    para2_adt:c2().

ct1_adt() ->
    para2_adt:ct1().

ct2_adt() ->
    para2_adt:ct2().

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-opaque circ(A) :: circ(A, A).
-opaque circ(A, B) :: circ({A, B}).

tcirc() ->
    A = circ1(),
    B = circ2(),
    A =:= B. % can never evaluate to 'true'

-spec circ1() -> circ(integer()).

circ1() ->
    3.

-spec circ2() -> circ(integer(), integer()).

circ2() ->
    {3, 3}.

tcirc_adt() ->
    A = circ1_adt(),
    B = circ2_adt(),
    A =:= B. % opaque attempt (number of parameters differs)

circ1_adt() ->
    para2_adt:circ1().

circ2_adt() ->
    para2_adt:circ2().

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

u_adt() ->
    A = u1_adt(),
    B = u2_adt(),
    %% The resulting types are equal, but not the parameters:
    A =:= B. % opaque attempt

u1_adt() ->
    para2_adt:u1().

u2_adt() ->
    para2_adt:u2().