blob: 2344bcc1a0c1dbfa4b58ddc862fbd3a7571792d7 (
plain)
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
|
/* PERMUTE_ARGS: -O -inline
*/
// https://issues.dlang.org/show_bug.cgi?id=22115
int sx;
void sss() { ++sx; }
static if (1)
{
struct S { int a; }
void test1(S* s)
{
if (s.a == 3 ? s : null)
sss();
}
}
static if (1)
{
extern (C++) class Exp
{
int a;
void func() { }
final inout(AddExp) isAddExp() inout { return a == 3 ? cast(typeof(return))this : null; }
}
extern (C++) class AddExp : Exp
{
}
void test2(Exp e)
{
if (e.isAddExp())
sss();
}
}
int main()
{
static if (1)
{
S s;
s.a = 3;
test1(&s);
assert(sx == 1);
s.a = 2;
test1(&s);
assert(sx == 1);
}
sx = 1;
static if (1)
{
auto c = new AddExp();
c.a = 3;
test2(c);
assert(sx == 2);
auto ae = c.isAddExp();
assert(ae && ae.a == 3);
c.a = 2;
test2(c);
assert(sx == 2);
}
return 0;
}
|