2 // EXTRA_FILES: imports/fwdref9514.d imports/fwdref12201a.d
4 /***************************************************/
5 // https://issues.dlang.org/show_bug.cgi?id=6766
10 void test(Foo6766 foo
= new Foo6766(1)) { }
16 void test(Bar6766 bar
= Bar6766(1)) { }
19 /***************************************************/
20 // https://issues.dlang.org/show_bug.cgi?id=8609
36 Tuple8609
!(Foo8609a
) spam() { return Tuple8609
!(Foo8609a
)(); }
48 Tuple8609
!(Foo8609b
[1]) spam() { return Tuple8609
!(Foo8609b
[1])(); }
51 /***************************************************/
52 // https://issues.dlang.org/show_bug.cgi?id=8698
54 interface IRoot8698a
{}
55 interface IClass8698a
: IRoot8698a
{ }
56 struct Struct8698a
{ }
57 class Class8698a
: IClass8698a
{ alias Struct8698a Value
; }
58 void test8698a(Class8698a
.Value
) { }
59 //interface IRoot8698a {}
63 //interface IRoot8698b {}
64 interface IClass8698b
: IRoot8698b
{ }
65 struct Struct8698b
{ }
66 class Class8698b
: IClass8698b
{ alias Struct8698b Value
; }
67 void test8698b(Class8698b
.Value
) { }
68 interface IRoot8698b
{}
70 /***************************************************/
71 // https://issues.dlang.org/show_bug.cgi?id=9514
73 template TStructHelpers9514a()
75 void opEquals(Foo9514a
)
77 auto n
= FieldNames9514a
!();
83 mixin TStructHelpers9514a
!();
86 import imports
.fwdref9514
: find9514
; // selective import without aliasing
88 template FieldNames9514a()
90 static if (find9514
!`true`([1])) enum int FieldNames9514a
= 1;
95 template TStructHelpers9514b()
97 void opEquals(Foo9514b
)
99 auto n
= FieldNames9514b
!();
105 mixin TStructHelpers9514b
!();
108 import imports
.fwdref9514
: foo9514
= find9514
; // selective import with aliasing
110 template FieldNames9514b()
112 static if (foo9514
!`true`([1])) enum int FieldNames9514b
= 1;
115 /***************************************************/
116 // https://issues.dlang.org/show_bug.cgi?id=10015
118 struct S10015(T
) { alias X
= int; }
120 alias Y10015
= s10015
.X
;
123 /***************************************************/
124 // https://issues.dlang.org/show_bug.cgi?id=10101
128 mixin template reflectRange10101()
130 static if (is(typeof(this.front10101
)))
140 typeof(r_
.front10101
) front10101() @property { return r_
.front10101
; }
142 mixin reflectRange10101
;
150 /***************************************************/
151 // https://issues.dlang.org/show_bug.cgi?id=11019
155 A11019
View() { return null; }
158 class B11019
: A11019
160 override D11019
View() { return null; }
163 class D11019
: B11019
{}
165 /***************************************************/
166 // https://issues.dlang.org/show_bug.cgi?id=11166
168 template Tup11166(T
...) { alias Tup11166
= T
; }
172 enum S11166a a
= S11166a(0);
173 enum S11166a b
= S11166a(1);
179 // only triggered when private and a template instance.
180 private alias types
= Tup11166
!(a
, b
);
185 enum S11166b a
= S11166b(0);
186 enum S11166b b
= S11166b(1);
188 // not at the last of members
189 alias types
= Tup11166
!(a
, b
);
196 /***************************************************/
197 // https://issues.dlang.org/show_bug.cgi?id=12152
204 class B12152
: A12152
209 static assert(is(A12152
.Y
== int));
211 /***************************************************/
212 // https://issues.dlang.org/show_bug.cgi?id=12201
216 alias imports
.fwdref12201a
.FILE
* FP
;
222 import imports
.fwdref12201a
;
228 import imports
.fwdref12201a
;
234 import imports
.fwdref12201a
;
240 import imports
.fwdref12201a
;
247 import imports
.fwdref12201a
;
249 mixin template TM12201()
252 import imports
.fwdref12201a
;
256 alias ti
= TI12201
!();
261 /***************************************************/
262 // https://issues.dlang.org/show_bug.cgi?id=12531
277 /***************************************************/
278 // https://issues.dlang.org/show_bug.cgi?id=12543
281 static assert(C12543
.sizeof
== (void*).sizeof
);
282 static assert(C12543
.alignof
== (void*).sizeof
);
283 static assert(C12543
.mangleof
== "C10testfwdref6C12543");
285 /***************************************************/
286 // https://issues.dlang.org/show_bug.cgi?id=14010
289 static assert(E14010
.mangleof
== "E10testfwdref6E14010");
292 static assert(S14010
.mangleof
== "S10testfwdref6S14010");
294 /***************************************************/
295 // https://issues.dlang.org/show_bug.cgi?id=12983
298 class B12983(T
) { alias MyC
= C12983
!string
; }
300 class C12983(T
) : B12983
!float
302 void m() { f12983(0); }
305 alias MyB12983
= B12983
!float;
310 /***************************************************/
311 // https://issues.dlang.org/show_bug.cgi?id=12984
313 class B12984a
{ alias MyD
= D12984a
!int; }
314 class C12984a
: B12984a
{ }
316 class D12984a(T
) { alias MyE
= E12984a
!float; }
317 class E12984a(T
) : D12984a
!int
321 auto c
= new C12984a();
325 static assert(__traits(classInstanceSize
, B12984a
) == (void*).sizeof
* 2);
326 static assert(__traits(classInstanceSize
, C12984a
) == (void*).sizeof
* 2);
330 class B12984b
{ int b
; alias MyD
= D12984b
!int; }
331 class C12984b
: B12984b
{ int c
; }
333 class D12984b(T
) { int d
; alias MyE
= E12984b
!float; }
334 class E12984b(T
) : D12984b
!int
339 auto c
= new C12984b();
343 static assert(__traits(classInstanceSize
, B12984b
) == (void*).sizeof
* 2 + int.sizeof
);
344 static assert(__traits(classInstanceSize
, C12984b
) == (void*).sizeof
* 2 + int.sizeof
* 2);
346 /***************************************************/
347 // https://issues.dlang.org/show_bug.cgi?id=14390
349 class B14390a
{ alias MyD
= D14390a
!int; }
350 class C14390a
: B14390a
{ void f(int) {} }
351 class D14390a(T
) { alias MyE
= E14390a
!float; }
352 class E14390a(T
) : D14390a
!int { void m() { auto c
= new C14390a(); } }
354 class B14390b
{ alias MyD
= D14390b
!int; }
355 class C14390b
: B14390b
{ static struct S
{} }
356 class D14390b(T
) { alias MyE
= E14390b
!float; }
357 class E14390b(T
) : D14390b
!int { void m() { auto c
= new C14390b(); } }
359 /***************************************************/
360 // https://issues.dlang.org/show_bug.cgi?id=13860
365 pure nothrow @nogc @safe void()
366 pure nothrow @nogc @safe void()
370 struct Foo13860(Bar
...)
373 auto baz(size_t d
)() {}
374 pragma(msg
, typeof(baz
!0));
377 auto bar13860(S
, R
)(S s
, R r
)
379 pragma(msg
, typeof(Foo13860
!().baz
!0));
389 /***************************************************/
390 // https://issues.dlang.org/show_bug.cgi?id=14083
394 int foo(NA14083 a
) { return 1; }
395 int foo(NB14083 a
) { return 2; }
397 class NA14083
: NBase14083
400 this(int v
) { this.v
= v
; }
402 class NB14083
: NBase14083
404 override int foo(NA14083 a
) { return a
.v
; }
409 int foo(TA14083
!T a
) { return 1; }
410 int foo(TB14083
!T a
) { return 2; }
412 class TA14083(T
) : TBase14083
!T
415 this(T v
) { this.v
= v
; }
417 class TB14083(T
) : TBase14083
!T
419 override int foo(TA14083
!T a
) { return a
.v
; }
424 NA14083 na
= new NA14083(10);
425 NB14083 nb
= new NB14083();
426 assert(na
.foo(na
) == 1);
427 assert(na
.foo(nb
) == 2);
428 assert(nb
.foo(na
) == 10);
430 TA14083
!int ta
= new TA14083
!int(10);
431 TB14083
!int tb
= new TB14083
!int();
432 assert(ta
.foo(ta
) == 1);
433 assert(ta
.foo(tb
) == 2);
434 assert(tb
.foo(ta
) == 10);
439 /***************************************************/
440 // https://issues.dlang.org/show_bug.cgi?id=14549
444 static if (T
.tupleof
.length
>= 0)
450 mixin(foo14549
!(typeof(this)));
452 static if (__traits(compiles
, undefined
))
460 static if (!__traits(isVirtualMethod
, this.bar
)) {}
468 mixin(code14549
!(typeof(this)));
471 template code14549(T
)
473 enum string code14549
=
474 q
{ static if (!__traits(isVirtualMethod
, "boo")) {} };
484 // https://issues.dlang.org/show_bug.cgi?id=14609
487 interface Foo14609(T
)
489 static if (is(T
== int))
492 class Frop14609
: Foo14609
!int
494 public int bar() { return 0; }
497 /***************************************************/
498 // test case 1, comes from Phobos
503 +anySatisfy, T.length == 1
505 +T.stringof in StaticArrayTypeOf
506 -T.stringof in StaticArrayTypeOf
508 +hasElaborateCpCtor S == struct or else
509 -hasElaborateCpCtor S == struct or else
510 -anySatisfy, T.length == 1
515 template anySatisfy15726x(alias F
, T
...)
517 //static if (T.length == 1)
519 pragma(msg
, "+anySatisfy, T.length == 1");
520 enum anySatisfy15726x
= F
!(T
[0]);
521 pragma(msg
, "-anySatisfy, T.length == 1");
525 template StaticArrayTypeOf15726x(T
)
529 static if (is(X
: E
[n
], E
, size_t n
))
531 //alias StaticArrayTypeOf15726x = X;
535 pragma(msg
, "+T.stringof in StaticArrayTypeOf");
536 // Fixed: T.stringof (T == Class12540) should not invoke
537 // T.size() in ClassDeclaration.search().
538 static assert(0, T
.stringof
~" is not a static array type");
539 pragma(msg
, "-T.stringof in StaticArrayTypeOf");
543 //enum bool isStaticArray(T) = is(StaticArrayTypeOf15726x!T);
544 template isStaticArray15726x(T
)
546 pragma(msg
, "+isStaticArray");
547 enum bool isStaticArray15726x
= is(StaticArrayTypeOf15726x
!T
);
548 pragma(msg
, "-isStaticArray");
551 template hasElaborateCpCtor15726x(S
)
553 static if (isStaticArray15726x
!S
&& S
.length
)
556 enum bool hasElaborateCpCtor15726x
=
557 hasElaborateCpCtor15726x
!(typeof(S
.init
[0]));
562 pragma(msg
, "+hasElaborateCpCtor S == struct or else");
563 static if (is(S
== struct))
565 enum bool hasElaborateCpCtor15726x
= true;
566 //enum hasElaborateCpCtor15726x = hasMember!(S, "__postblit")
567 // || anySatisfy15726x!(.hasElaborateCpCtor15726x, FieldTypeTuple!S);
571 enum bool hasElaborateCpCtor15726x
= false;
573 pragma(msg
, "-hasElaborateCpCtor S == struct or else");
577 struct VariantN15726x(AllowedTypesParam
...)
579 alias AllowedTypes
= AllowedTypesParam
;
581 static if (!AllowedTypes
.length ||
582 anySatisfy15726x
!(hasElaborateCpCtor15726x
, AllowedTypes
))
587 template Algebraic15726x(T
)
589 alias Algebraic15726x
= VariantN15726x
!(T
);
594 static struct DummyScope
596 pragma(msg
, "+alias Alias12540");
597 alias Alias12540
= Algebraic15726x
!Class12540
;
598 pragma(msg
, "-alias Alias12540");
599 static class Class12540
606 /***************************************************/
607 // test case 2, comes from Phobos
609 struct RefCounted15726y(T
)
611 struct RefCountedStore
619 RefCountedStore _refCounted
;
625 _refCounted
._store
._payload
.__xdtor();
629 struct RangeT15726y(A
)
632 alias RC
= RangeT15726y
!(const(A
));
635 struct Array15726y(T
)
642 alias Data
= RefCounted15726y
!(Payload
);
645 alias Range
= RangeT15726y
!Array15726y
;
650 alias Range
= RangeT15726y
!(Array15726y
!int);
655 /***************************************************/
656 // https://issues.dlang.org/show_bug.cgi?id=15726
669 destroy15726a(_store
._payload
);
677 alias Stmt15726a
= .Stmt15726a
!T
;
682 alias Con15726a
= .Con15726a
!T
;
684 RC15726
!Payload data
;
692 Con15726a
!int x15726a
;
694 void destroy15726a(T
)(ref T obj
) @trusted
696 auto buf
= (cast(ubyte*)&obj
)[0 .. T
.sizeof
];
701 struct Util15726b(C
, S
) {}
705 alias Util15726b
= .Util15726b
!(Con15726b
!T
, Stmt15726b
!T
);
715 RC15726
!Payload data
;
718 Con15726b
!int x15726b
;