Debian Codegraph @

gcc/testsuite/gdc.test/compilable/test3673.d

raw
1 class Base {}
2
3 class Foo(T)
4 if (is(T == int)) : Base { }
5
6 class Bar(T) : Base
7 if (is(T == bool))
8 { }
9
10 interface OutputRange(T...)
11 if (T.length == 1)
12 {
13 void put(T[0] value);
14 }
15
16 interface OutputRange(T...) : OutputRange!(T[0]), OutputRange!(T[1 .. $])
17 if (T.length > 1)
18 {
19 }
20
21 alias OutputRange!(int, float) OR;
22
23 class COR : OR
24 {
25 void put(int) { }
26 void put(float) { }
27 }
28
29 class A {};
30 class B(T) : A if (true) {}
31 class C(T) if (false) : A {}
32
33 alias Foo!int FooInt;
34 alias Bar!bool BarBool;
35
36 static assert(!__traits(compiles, Foo!bool));
37 static assert(!__traits(compiles, Bar!int));
38
39 void main()
40 {
41 auto fi = new FooInt;
42 auto bb = new BarBool;
43 auto cor = new COR;
44
45 auto a = new A();
46 auto b = new B!int();
47 static assert(!__traits(compiles, new C!int()));
48 }