| 1 |
// https://issues.dlang.org/show_bug.cgi?id=16574 |
| 2 |
template Recursive(T) if (is(T == class)) |
| 3 |
{ |
| 4 |
// fails because T is still forward referenced |
| 5 |
// speculative determineSize must not set type to error |
| 6 |
static assert (!__traits(compiles, { new T; })); |
| 7 |
// known size of class |
| 8 |
static assert (is(typeof(T.init) == T)); |
| 9 |
|
| 10 |
alias Recursive = T; |
| 11 |
} |
| 12 |
|
| 13 |
// must be resolvable |
| 14 |
class C |
| 15 |
{ |
| 16 |
Recursive!C r; |
| 17 |
} |
| 18 |
|
| 19 |
template Recursive(T) if (is(T == struct)) |
| 20 |
{ |
| 21 |
// fails because T is still forward referenced |
| 22 |
// speculative determineSize must not set type to error |
| 23 |
static assert (!__traits(compiles, { T t; })); |
| 24 |
// no size yet for struct |
| 25 |
static assert (!is(typeof(T.init))); |
| 26 |
|
| 27 |
alias Recursive = T*; |
| 28 |
} |
| 29 |
|
| 30 |
// must be resolvable |
| 31 |
struct S |
| 32 |
{ |
| 33 |
Recursive!S r; |
| 34 |
} |